#include #include #include using namespace std; typedef long long ll; ll mod = 1000000007; vector A[100010],l[1000],r[1000]; int main(){ int i,j,h,w; cin >> h >> w; bool flag = false; if(h>w) flag = true,swap(h,w); if(!flag){ for(i=0;i> v; A[i].push_back(v); } } }else{ for(i=0;i> v; A[i].push_back(v); } } } for(i=0;i=0;j--){ ll b = r[i].back(); r[i].push_back(A[i][j]*b%mod); } reverse(r[i].begin(),r[i].end()); } ll q; cin >> q; for(i=0;i> rr >> c; rr--; c--; if(flag) swap(rr,c); ll ans = 1; for(j=0;j0) (ans *= l[j][c - 1]) %= mod; if(c