loop do
  a,b = gets.split(" ").map(&:to_i)
  break if a == 0 && b == 0
  m = gets.to_i
  koji = Array.new(m) { gets.split(" ").map(&:to_i) }

  dp = Array.new(a+1) {Array.new(b+1){0}}
  dp[1][0] = 1
  koji.each {|co| dp[co[0]][co[1]] = -1}

  1.upto(a) do |i|
    1.upto(b) do |j|
      if dp[i][j] == 0
        dp[i][j] = dp[i-1][j] + dp[i][j-1]
      else
        dp[i][j] = 0
      end
    end
  end
  
  puts dp[a][b]
end