while true do
  a, b = gets.split.map(&:to_i)
  break if (a|b) == 0

  mass = Array.new(a+1, 0).map{ Array.new(b+1, 0) }
  mass[1][0] = 1

  n = gets.to_i
  n.times do
    x, y = gets.split.map(&:to_i)
    mass[x][y] = nil
  end

  for i in 1..a
    for j in 1..b
      if mass[i][j] == nil
        mass[i][j] = 0
      else
        mass[i][j] = mass[i-1][j] + mass[i][j-1]
      end
    end
  end
  puts mass[a][b]
end