func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const double EPS = 1e-8;   const double PI = 2 * acos(0);   const int MAXN = 2006;   struct Node {     int x, y;     bool operator<(Node b) const {       if (x != b.x) return x < b.x;       return y < b.y;     }   };   struct Math {     int n;     int MOD;     int SMALL_N;     long long *r;     long long *fac, *ifac;     long long **A, **C;     long long *twop, *iv_twop;     Math() {       n = -1;       MOD = 1;       SMALL_N = 3030;     }     void prepare(int n_, int MOD_) {       n = n_;       MOD = MOD_;       r = new long long[n + 1];       r[1] = 1;       for (int i = 2; i <= n; ++i)         r[i] = (MOD - (MOD / i) * r[MOD % i] % MOD) % MOD;       fac = new long long[n + 1];       fac[0] = 1;       for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % MOD;       ifac = new long long[n + 1];       ifac[0] = ifac[1] = 1;       for (int i = 2; i <= n; ++i) ifac[i] = ifac[i - 1] * r[i] % MOD;       twop = new long long[n + 1];       iv_twop = new long long[n + 1];       twop[0] = iv_twop[0] = 1;       twop[1] = 2;       iv_twop[1] = (MOD + 1) / 2;       for (int i = 2; i <= n; ++i) {         twop[i] = twop[i - 1] * 2 % MOD;         iv_twop[i] = iv_twop[i - 1] * iv_twop[1] % MOD;       }       if (n <= SMALL_N) {         A = new long long *[n + 1];         for (int i = 0; i <= n; ++i) A[i] = new long long[n + 1];         memset(A, 0, sizeof(A));         for (int i = 0; i <= n; ++i) A[i][0] = 1;         for (int i = 1; i <= n; ++i)           for (int j = 1; j <= i; ++j) A[i][j] = A[i][j - 1] * (i - j + 1) % MOD;       }       if (n <= SMALL_N) {         C = new long long *[n + 1];         for (int i = 0; i <= n; ++i) C[i] = new long long[n + 1];         memset(C, 0, sizeof(C));         for (int i = 0; i <= n; ++i) C[i][0] = C[i][i] = 1;         for (int i = 1; i <= n; ++i)           for (int j = 1; j < i; ++j)             C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % MOD;       }     }     long long getA(int n_, int k_) {       if (k_ < 0 || n_ < 0) return 0;       if (n_ <= n && n <= SMALL_N) return A[n_][k_];       return fac[n_] * ifac[n_ - k_] % MOD;     }     long long getC(int n_, int k_) {       if (k_ < 0 || n_ < 0) return 0;       if (n_ <= n && n <= SMALL_N) return C[n_][k_];       return fac[n_] * ifac[n_ - k_] % MOD * ifac[k_] % MOD;     }   };   int n, m, k;   Node node[MAXN];   long long dp[MAXN];   Math toan;   bool input() {     int u, v, x, y;     cin >> n >> m >> k;     for (int i = 1; i <= k; ++i) cin >> node[i].x >> node[i].y;     return !cin.fail();   }   void clear_input() { k = 0; }   void preprocess() {     sort(node + 1, node + k + 1);     toan.prepare(200005, MOD);   }   void process(int itest) {     int u, v, x, y;     node[k + 1].x = n, node[k + 1].y = m;     for (int i = 1; i <= k + 1; ++i) {       x = node[i].x;       y = node[i].y;       dp[i] = toan.getC(x + y - 2, x - 1);       for (int j = 1; j < i; ++j)         if (node[j].x <= x && node[j].y <= y)           dp[i] = ((dp[i] - dp[j] * toan.getC(x - node[j].x + y - node[j].y,                                               x - node[j].x)) %                        MOD +                    MOD) %                   MOD;     }     cout << dp[k + 1] << endl;   }   void oneTest() {     while (input()) {       preprocess();       process(0);       clear_input();     }   }   void multiTest() {     int t;     cin >> t;     for (int it = 1; it <= t; ++it) {       input();       preprocess();       process(it);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     oneTest();     return 0;   }   