#include #define show(x) std::cerr << #x << " = " << (x) << std::endl 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 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; }; template std::ostream& operator<<(std::ostream& os, const std::vector& v) { os << "["; for (const auto& p : v) { os << p << ","; } return (os << "]\n"); } int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); 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> memo1(K + 2, std::vector(K + 2, -1)); auto dp1 = [&](auto&& self, const int s, const int g) -> ll { if (memo1[s][g] != -1) { return memo1[s][g]; } ll ans = d[s][g]; for (int i = 1; i <= K; i++) { if (i == s or i == g or d[i][g] == 0) { continue; } const ll minus = self(self, s, i) * d[i][g] % MOD; (ans += (MOD - minus)) %= MOD; } return memo1[s][g] = ans; }; std::vector> memo2(K + 2, std::vector(1 << K, -1)); auto dp2 = [&](auto&& self, const int s, const int used) -> ll { if (memo2[s][used] != -1) { return memo2[s][used]; } ll ans = dp1(dp1, s, K + 1); for (int i = 1; i <= K; i++) { if (s == i or d[s][i] == 0 or ((used >> (i - 1)) & 1) == 0) { continue; } (ans += dp1(dp1, s, i) * self(self, i, used - (1 << (i - 1))) % MOD) %= MOD; } return memo2[s][used] = ans; }; std::vector ans(1 << K); for (int i = 0; i < (1 << K); i++) { ans[i] = dp2(dp2, 0, i); } for (int q = 0; q < (1 << K); q++) { std::cout << ans[(1 << K) - 1 - q] << "\n"; } return 0; }