#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define rep(i, n) for(int i=0;i=0;--i) const int inf=1e9+7; const ll mod=1e9+7; const ll big=1e18; const double PI=2*asin(1); int main() { int H, W; cin>>H>>W; ll A[H][W]; ll sumA = 1; ll tate[H], yoko[W]; for(int i=0;i>A[i][j]; sumA *= A[i][j]; sumA %= mod; tate[i] *= A[i][j]; tate[i] %= mod; yoko[j] *= A[i][j]; yoko[j] %= mod; } } int Q; cin>>Q; int r, c; ll tmp, tmpr, tmpc; ll h, two; for(int i=0;i>r>>c; r--; c--; tmp = sumA; tmp *= A[r][c]; tmp %= mod; h = mod - 2; while(h>0) { two = 1; tmpr = tate[r]; tmpc = yoko[c]; while(2*two