output_description: Print the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 +
  7.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      H W N
      r_1 c_1
      r_2 c_2
      :
      r_N c_N
attempt: import sys
  
  input = lambda: sys.stdin.readline().strip()
  
  
  class PERM_COMB_MOD:
      # http://drken1215.hatenablog.com/entry/2018/06/08/210000
      def __init__(self, max_n=510000, mod=10**9 + 7):
          self.fac = [0] * max_n
          self.finv = [0] * max_n
          self.inv = [0] * max_n
          self.fac[0] = self.fac[1] = 1
          self.finv[0] = self.finv[1] = 1
          self.inv[1] = 1
          self.max = max_n
          self.mod = mod
          self._maesyori()
  
      def _maesyori(self):
          for i in range(2, self.max):
              self.fac[i] = self.fac[i - 1] * i % self.mod
              self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
              self.finv[i] = self.finv[i - 1] * self.inv[i] % self.mod
  
      def comb(self, n, k):
          if n < k:
              return 0
          if n < 0 or k < 0:
              return 0
          return self.fac[n] * (self.finv[k] * self.finv[n - k] % self.mod) % self.mod
  
  
  mod = 10**9 + 7
  PCM = PERM_COMB_MOD(3 * 10**5, mod=mod)
  
  h, w, n = map(int, input().split())
  rc = [list(map(int, input().split())) for i in range(n)]
  rc.append([h, w])
  n += 1
  
  rc.sort()
  
  DP = [0] * (n + 1)
  # start地点
  DP[0] = 1
  for i in range(n):
      r, c = rc[i]
      DP[i + 1] = PCM.comb(r - 1 + c - 1, r - 1)
      for j in range(i):
          rj, cj = rc[j]
          if rj <= r and cj <= c:
              DP[i + 1] -= DP[j + 1] * PCM.comb(r - rj + c - cj, r - rj)
      DP[i + 1] %= mod
  
  print(DP[-1])
  
problem_description: Statement
  
  There is a grid with H horizontal rows and W vertical columns. Let (i, j)
  denote the square at the i-th row from the top and the j-th column from the
  left.
  
  In the grid, N Squares (r_1, c_1), (r_2, c_2), \ldots, (r_N, c_N) are wall
  squares, and the others are all empty squares. It is guaranteed that Squares
  (1, 1) and (H, W) are empty squares.
  
  Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right
  or down to an adjacent empty square.
  
  Find the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.
samples: [{"input": "3 4 2\n    2 2\n    1 4", "output": "3\n    \n\nThere are three paths as follows:\n\n![](https://img.atcoder.jp/dp/grid_1_0_muffet.png)\n\n* * *"}, {"input": "5 2 2\n    2 1\n    4 2", "output": "0\n    \n\nThere may be no paths.\n\n* * *"}, {"input": "5 5 4\n    3 1\n    3 5\n    1 3\n    5 3", "output": "24\n    \n\n* * *"}, {"input": "100000 100000 1\n    50000 50000", "output": "123445622\n    \n\nBe sure to print the count modulo 10^9 + 7."}]