while 1
    n, m, t, p = gets.split.map(&:to_i)
    a = (1..m).map{(1..n).map {1}}
    break if n == 0
    t.times do
        d, c = gets.split.map(&:to_i)
        if d == 1
            n = [c, n - c].max
            a.map! do |row|
                left = row[0..c-1].reverse
                right = row[c..-1]
                (0..n-1).map {|i| (left[i] || 0) + (right[i] || 0)}
            end
        else
            m = [c, m - c].max
            lower = a[0..c-1].reverse
            upper = a[c..-1]
            a = (0..m-1).map {|i|
                (upper[i] || Array.new(n, 0)).zip(lower[i] || Array.new(n, 0)).map {|r| r.inject(:+)}
            }
        end
    end
    p.times do
        x, y = gets.split.map(&:to_i)
        p a[y][x]
    end
end

