/*************************************** zzblack ** 2016-04-22 ** Orz ** ****************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ls id<<1,l,mid #define rs id<<1|1,mid+1,r #define OFF(x) memset(x,-1,sizeof x) #define CLR(x) memset(x,0,sizeof x) #define MEM(x) memset(x,0x3f,sizeof x) typedef long long ll ; typedef pair pii ; const int maxn = 1e3 + 50 ; const int maxm = 1e6 + 50; const double eps = 1e-10; const int max_index = 62; const int inf = 0x3f3f3f3f ; const int MOD = 1e9+7 ; inline int read(){ char c = getchar(); while (!isdigit(c)) c = getchar(); int x = 0; while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } return x; } int locr[maxn], locc[maxn]; int addr[maxn], addc[maxn]; int a[maxn][maxn]; int main () { #ifdef LOCAL freopen("C:\\Users\\zzblack\\Desktop\\case.in","r",stdin); // freopen("C:\\Users\\zzblack\\Desktop\\case.out","w",stdout); #endif int T = read(); while (T--) { int n = read(), m = read(), q = read(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { a[i][j] = read(); } } for (int i = 1; i <= n; i++) locr[i] = i, addr[i] = 0; for (int i = 1; i <= m; i++) locc[i] = i, addc[i] = 0; while (q--) { int op = read(), x = read(), y = read(); if (op == 1) { swap(locr[x], locr[y]); } else if (op == 2) { swap(locc[x], locc[y]); } else if (op == 3) { x = locr[x]; addr[x] += y; } else { x = locc[x]; addc[x] += y; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { int x = locr[i], y = locc[j]; // printf("%d %d\n", x, y); printf("%d%c", a[x][y] + addr[x] + addc[y], j == m ? '\n' : ' '); } } } return 0; }