#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long up = 2e5 + 5;   pair<int, int> pt[2005];   inline bool cmp(const pair<int, int>& a, const pair<int, int>& b) {     if (a.first == b.first) return a.second < b.second;     return a.first < b.first;   }   long long fac[up], inv[up], facinv[up], facinv2[up];   long long pow_mod(long long a, long long k) {     long long res = 1;     while (k) {       if (k & 1) res = (res * a) % mod;       a = (a * a) % mod;       k >>= 1;     }     return res;   }   void init() {     fac[0] = fac[1] = 1;     for (long long i = 2; i < up; ++i) fac[i] = fac[i - 1] * i % mod;     inv[1] = 1, facinv[0] = facinv[1] = 1;     facinv2[0] = facinv2[1] = 1;     for (long long i = 2; i < up; ++i) {       long long t = mod / i, k = mod % i;       inv[i] = i * t * t % mod * inv[k] % mod * inv[k] % mod;       facinv[i] = facinv[i - 1] * inv[i] % mod;     }   }   long long C(long long n, long long m) {     return fac[n] * facinv[n - m] % mod * facinv[m] % mod;   }   long long ans[2005];   int main() {     init();     int h, w, k;     cin >> h >> w >> k;     for (long long i = 0; i < k; ++i) cin >> pt[i].first >> pt[i].second;     pt[k].first = h, pt[k].second = w;     ++k;     sort(pt, pt + k, cmp);     for (long long i = 0; i < k; ++i) {       ans[i] = C(pt[i].first + pt[i].second - 2, pt[i].first - 1);       for (long long j = 0; j < i; ++j) {         ans[i] -= ans[j] *                   C(pt[i].first - pt[j].first + pt[i].second - pt[j].second,                     pt[i].first - pt[j].first) %                   mod;         ans[i] = (ans[i] + mod) % mod;       }     }     cout << ans[k - 1] << endl;   }   