/*Sherlock and Watson and Adler*/ #pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define exp 1e-10 #define ll long long using namespace std; const int N = 1005; const int M = 10000 + 10; const int inf = 100000000; const int mod = 2009; __int64 s[N][N],s2[N][N]; struct node { __int64 sum; }r[N],c[N]; int pr[N],pc[N]; int main() { int t,n,m,q,a,x,y,i,j; scanf("%d",&t); while(t--) { memset(r,0,sizeof(r)); memset(c,0,sizeof(c)); scanf("%d%d%d",&n,&m,&q); for(i=1;i<=n;i++) { pr[i]=i; for(j=1;j<=m;j++) { pc[j]=j; s2[i][j]=0; scanf("%I64d",&s[i][j]); } } for(i=0;i