class SchoolRoad
  def initialize(x, y)
    @x = x
    @y = y
    @grid = Array.new(y+1).map{Array.new(x+1, 0)}
    @grid[1][1] = 1
  end

  def set_under_constraction(x, y)
    @grid[y][x] = nil
  end

  def solve
    (1..@y).each do |i|
      (1..@x).each do |j|
        next if @grid[i][j].nil?
        @grid[i][j] += get_grid_num(i-1, j) + get_grid_num(i, j-1)
      end
    end
    @grid[@y][@x]
  end

  def get_grid_num(i, j)
    (@grid[i][j].nil? ? 0 : @grid[i][j])
  end
end

def make_school_road(x, y)
  school_road = SchoolRoad.new(x, y)
  n = gets.chomp.to_i
  n.times do
    xi, yi = gets.chomp.split.map(&:to_i)
    school_road.set_under_constraction(xi, yi)
  end
  school_road
end

def main
  loop do
    x, y = gets.chomp.split.map(&:to_i)
    break if (x|y) == 0
    puts make_school_road(x, y).solve
  end
end

main