#include using ll = long long; constexpr ll MOD = 100000007; template class ModCombination { public: ModCombination(const std::size_t n) : fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1) { for (ll i = 2; i <= (ll)n; i++) { fact[i] = (fact[i - 1] * i) % mod, inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod, inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod; } } ll factorial(const std::size_t n) const { return fact[n]; } ll inverse(const std::size_t n) const { return inv[n]; } ll inverseFactorial(const std::size_t n) const { return inv_fact[n]; } ll permutation(const std::size_t n, const std::size_t k) const { return (fact[n] * inv_fact[n - k]) % mod; } ll combination(const std::size_t n, const std::size_t k) const { return (((fact[n] * inv_fact[k]) % mod) * inv_fact[n - k]) % mod; } private: std::vector fact, inv, inv_fact; }; int main() { int H, W, K; std::cin >> H >> W >> K; ModCombination<> mod(H + W); std::vector a(K + 2), b(K + 2); a[0] = b[0] = 0, a[K + 1] = H, b[K + 1] = W; for (int i = 1; i <= K; i++) { std::cin >> a[i] >> b[i]; } std::vector> d(K + 2, std::vector(K + 2, 0)); for (int i = 0; i < K + 2; i++) { for (int j = 0; j < K + 2; j++) { if (a[i] <= a[j] and b[i] <= b[j]) { d[i][j] = mod.combination(a[j] + b[j] - a[i] - b[i], a[j] - a[i]); } } } std::vector memo(K + 2, -1); auto dp = [&](auto&& self, const int s) -> ll { if (memo[s] != -1) { return memo[s]; } ll ans = d[s][K + 1]; for (int i = 0; i <= K; i++) { if (i == s or d[s][i] == 0) { continue; } const ll minus = d[s][i] * self(self, i) % MOD; (ans += (MOD - minus)) %= MOD; } return memo[s] = ans; }; for (int q = 0; q < (1 << K); q++) { auto at = [&](const int j) -> bool { return ((q >> j) & 1) == 0; }; ll ans = dp(dp, 0); for (int i = 1; i <= K; i++) { const int j = i - 1; if (at(j)) { (ans += dp(dp, i) * d[0][i] % MOD) %= MOD; } } std::cout << ans << std::endl; } return 0; }