#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]; int tatezero[H], yokozero[W]; int zeronum = 0; for(int i=0;i>A[i][j]; if(A[i][j]==0) { zeronum++; tatezero[i]++; yokozero[j]++; continue; } 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--; if(A[r][c]==0) { if(tatezero[r]+yokozero[c]-1!=zeronum) { cout<<0<0) { two = 1; tmpr = tate[r]; tmpc = yoko[c]; while(2*two