#include #include #include using namespace std; #define N 1005 int a[N][N],row[N],col[N],crow[N],ccol[N]; int n,m,q,i,j,op,x,y,T; int main(){ scanf("%d",&T); while (T--){ scanf("%d%d%d",&n,&m,&q); for (i=1;i<=n;i++){ for (j=1;j<=m;j++){ scanf("%d",&a[i][j]); } } for (i=1;i<=n;i++) {row[i]=i;crow[i]=0;} for (i=1;i<=m;i++) {col[i]=i;ccol[i]=0;} for (i=1;i<=q;i++){ scanf("%d%d%d",&op,&x,&y); switch(op){ case 1:{ swap(row[x],row[y]); break; } case 2:{ swap(col[x],col[y]); break; } case 3:{ crow[row[x]]+=y; break; } case 4:{ ccol[col[x]]+=y; } } } for (i=1;i<=n;i++){ for (j=1;j