func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<pair<long long, long long> > bl;   long long fact[200005];   long long ifact[200005];   long long invert_mod(long long a, long long p) {     long long n = 1, old = 0, q = p, r, h;     bool pos = false;     while (a > 0) {       r = q % a;       q = q / a;       h = q * n + old;       old = n;       n = h;       q = a;       a = r;       pos = !pos;     }     return pos ? old : (p - old);   }   void calc_fact() {     fact[0] = fact[1] = 1;     ifact[0] = ifact[1] = 1;     for (long long i = 2; i < 200005; i++) {       fact[i] = (i * fact[i - 1]) % 1000000007;       ifact[i] = invert_mod(fact[i], 1000000007) % 1000000007;     }   }   int main(void) {     ios_base::sync_with_stdio(false);     long long h, w, n;     cin >> h >> w >> n;     calc_fact();     bl.resize(n);     for (int i = 0; i < n; i++) {       cin >> bl[i].first >> bl[i].second;     }     bl.push_back(make_pair(h, w));     vector<long long> dp(n + 1, 0);     sort(bl.begin(), bl.end());     dp[0] = ((fact[bl[0].first + bl[0].second - 2] * ifact[bl[0].first - 1]) %              1000000007 * ifact[bl[0].second - 1]) %             1000000007;     for (int i = 1; i <= n; i++) {       dp[i] = ((fact[bl[i].first + bl[i].second - 2] * ifact[bl[i].first - 1]) %                1000000007 * ifact[bl[i].second - 1]) %               1000000007;       long long ans = 0;       for (int j = 0; j < i; j++) {         long long val;         if (bl[i].second >= bl[j].second && bl[i].first >= bl[j].first)           val = ((fact[(bl[i].first + bl[i].second) -                        (bl[j].first + bl[j].second)] *                   ifact[bl[i].first - bl[j].first]) %                  1000000007 * ifact[bl[i].second - bl[j].second]) %                 1000000007;         else           val = 0;         ans = (ans + (dp[j] * val) % 1000000007) % 1000000007;       }       dp[i] = (dp[i] + (1000000007 - ans)) % 1000000007;     }     cout << dp[n];     return 0;   }   