#include using namespace std; using ll = long long; template T mod_pow(T x, T n, const T &p) { T ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; } const ll MOD = 1e9+7; int main() { int h,w; cin >> h >> w; vector> A(h,vector(w)),ans(h,vector(w)); ll cnt0all = 0; ll all = 1; for(int i = 0;i> A[i][j]; all = all*A[i][j]%MOD; if(A[i][j]==0)cnt0all++; } } vector row(h,1),col(w,1),row0(h,0),col0(w,0); for(int i = 0;i is0r(h),is0l(w); for(int i = 0;i> q; while(q--) { int now0 = cnt0all; ll r,c; cin >>r >> c; r--;c--; now0 -= row0[r] + col0[c] - (A[r][c]==0); if(now0>0) { cout<<0<