func_code_string: #include <bits/stdc++.h>   using namespace std;   long long fact[(long long)(1e6 + 10)], mod_inv[(long long)(1e6 + 10)];   long long _pow(long long a, long long n) {     if (n == 0) return 1;     if (n % 2 == 1) return (a * _pow(a, n - 1)) % (long long)(1e9 + 7);     long long x = _pow(a, n / 2) % (long long)(1e9 + 7);     return (x * x) % (long long)(1e9 + 7);   }   void inv() {     mod_inv[0] = 1;     for (int i = 1; i < (long long)(1e6 + 10) - 1; i++) {       mod_inv[i] = _pow(fact[i], (long long)(1e9 + 7) - 2);     }   }   void f() {     fact[0] = 1;     mod_inv[0] = 1;     for (int i = 1; i < (long long)(1e6 + 10) - 1; i++) {       fact[i] = fact[i - 1] * i;       fact[i] %= (long long)(1e9 + 7);       mod_inv[i] = _pow(fact[i], (long long)(1e9 + 7) - 2);     }   }   void init() { f(); }   long long nCr(long long n, long long r) {     return (((mod_inv[n - r] * mod_inv[r]) % (long long)(1e9 + 7)) * fact[n]) %            (long long)(1e9 + 7);   }   pair<long long, long long> black[2010];   bool cmp(pair<long long, long long> a, pair<long long, long long> b) {     return (a.first == b.first) ? a.second < b.second : a.first < b.first;   }   int main() {     std::ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     init();     int h, w, n;     cin >> h >> w >> n;     for (int i = 0; i < n; i++) {       cin >> black[i].first >> black[i].second;       black[i].first--;       black[i].second--;     }     long long dp[n + 1];     memset(dp, 0, sizeof(dp));     black[n] = make_pair(h - 1, w - 1);     sort(black, black + n, cmp);     for (int i = 0; i < n + 1; i++) {       dp[i] = nCr(black[i].first + black[i].second, black[i].first);       for (int j = 0; j < i; j++) {         if (black[j].second > black[i].second) continue;         dp[i] -= (dp[j] * nCr(black[i].first - black[j].first + black[i].second -                                   black[j].second,                               black[i].second - black[j].second)) %                  (long long)(1e9 + 7);         dp[i] += (long long)(1e9 + 7);         dp[i] %= (long long)(1e9 + 7);       }     }     cout << dp[n] << endl;     return 0;   }   