#include #include typedef long long ll; #define U 1050000 using namespace std; vector I, X, Y; int H, W, N; int MOD = 1e8 + 7; ll dp[U]; ll fact[U]; ll fact_inv[U]; ll mpow(ll a, ll n) { if (n == 0) { return 1; } ll x = mpow(a, n / 2); x = x * x % MOD; if (n & 1) { x = a * x % MOD; } return x; } void make_fact() { fact[0] = 1; for (int i = 1; i < U; i++) { fact[i] = i * fact[i - 1] % MOD; } fact_inv[U - 1] = mpow(fact[U - 1], MOD - 2); for (int i = U - 1; i > 0; i--) { fact_inv[i - 1] = fact_inv[i] * i % MOD; } } ll f(int S) { int x = 0; int y = 0; ll ret = 1; for (int r = 0; r < N; r++) { int i = I[r]; if (!(S & (1 << i))) { continue; } int x1 = X[r]; int y1 = Y[r]; int dx = x1 - x; int dy = y1 - y; if (dx < 0 || dy < 0) { return 0; } ret *= fact[dx + dy] * fact_inv[dx] % MOD * fact_inv[dy] % MOD; ret %= MOD; x = x1; y = y1; } int dx = H - x; int dy = W - y; ret *= fact[dx + dy] * fact_inv[dx] % MOD * fact_inv[dy] % MOD; return ret % MOD; } void mobius() { for (int i = 0; i < N; i++) { for (int n = 0; n < (1 << N); n++) { if (!(n & (1 << i))) { dp[n] -= dp[n ^ (1 << i)]; dp[n] %= MOD; continue; } } } } void zeta() { for (int i = 0; i < N; i++) { for (int n = 0; n < (1 << N); n++) { if (n & (1 << i)) { dp[n] += dp[n ^ (1 << i)]; dp[n] %= MOD; continue; } } } } int main() { make_fact(); cin >> H >> W >> N; for (int i = 0; i < N; i++) { int x, y; cin >> x >> y; I.push_back(i); X.push_back(x); Y.push_back(y); } // ι›‘γ‚½γƒΌγƒˆ for (int i = 0; i < N * N; i++) { for (int j = 0; j < N - 1; j++) { if (X[j] + Y[j] > X[j + 1] + Y[j + 1]) { swap(I[j], I[j + 1]); swap(X[j], X[j + 1]); swap(Y[j], Y[j + 1]); } } } for (int i = 0; i < (1 << N); i++) { dp[i] = f(i); } mobius(); zeta(); for (int i = (1 << N) - 1; i >= 0; i--) { ll x = dp[i]; if (x < 0) { x += MOD; } cout << x << "\n"; } return 0; }