#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2) #define MEM(a,b) memset(a,b,sizeof(a)) #define MP(a,b) make_pair(a,b) #define PB push_back typedef long long ll; typedef pair pii; const double eps = 1e-8; const int INF = (1 << 30) - 1; const int MAXN = 100010; int T; int n,m,q; int g[1010][1010]; int pr[1010],pc[1010]; ll ar[1010],ac[1010]; int main(){ scanf("%d",&T); while(T--){ scanf("%d%d%d",&n,&m,&q); for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ scanf("%d",&g[i][j]); } } memset(ar,0,sizeof(ar)); memset(ac,0,sizeof(ac)); for(int i = 1; i <= n; ++i) pr[i] = i; for(int i = 1; i <= m; ++i) pc[i] = i; for(int i = 1; i <= q; ++i){ int f,x,y; scanf("%d%d%d",&f,&x,&y); if(f == 1){ swap(pr[x],pr[y]); swap(ar[x],ar[y]); } else if(f == 2){ swap(pc[x],pc[y]); swap(ac[x],ac[y]); } else if(f == 3){ ar[x] += y; } else if(f == 4){ ac[x] += y; } } for(int i = 1; i <= n; ++i){ for(int j = 1; j <= m; ++j){ printf("%I64d",g[pr[i]][pc[j]] + ar[i] + ac[j]); if(j < m) printf(" "); else puts(""); } } } return 0; }