#include #include #include using namespace std; #define mod long(1e8 + 7) #define bitcount(n) __builtin_popcount(n) struct position{ int y, x; bool operator <(const position another) const{ return y < another.y; } }; long power(long base, int exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; } } vector factorial{1}; vector inverse_factorial{1}; long move_combination(int h, int w){ if(h < 0 || w < 0){ return 0; }else{ return factorial[h + w] * inverse_factorial[h] % mod * inverse_factorial[w] % mod; } } int main(){ int H, W, K; cin >> H >> W >> K; pair friendss[K]; for(int i = 0; i < K; i++){ position friends; cin >> friends.y >> friends.x; friendss[i] = {friends, i}; } sort(friendss, friendss + K); for(long i = 1; i <= 2e5; i++){ factorial.push_back(factorial.back() * i % mod); inverse_factorial.push_back(power(factorial.back(), mod - 2)); } long ans[1 << K]; for(int i = 0; i < (1 << K); i++){ vector destination; destination.push_back({0, 0}); for(int j = 0; j < K; j++){ if((i >> j) & 1){ destination.push_back(friendss[j].first); } } destination.push_back({H, W}); long this_ans = 1; for(int j = 1; j < destination.size(); j++){ this_ans *= move_combination(destination[j].y - destination[j - 1].y, destination[j].x - destination[j - 1].x); this_ans %= mod; } int i_position = 0; for(int j = 0; j < K; j++){ i_position += ((i >> j) & 1) * (1 << (friendss[j].second)); } if(bitcount(i) % 2){ ans[i_position] = mod - this_ans; }else{ ans[i_position] = this_ans; } } for(int i = 0; i < (1 << K); i++){ long an = 0; for(int j = i; j > 0; j = i & (j - 1)){ an += ans[j]; } an += ans[0]; printf("%d\n", an % mod); } }