#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair PII; #define fi first #define se second #define MP make_pair ll read() { ll v = 0, f = 1; char c = getchar(); while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();} while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar(); return v * f; } const ll N = 1001; ll n, m, q, a[N][N], b[N][N], t1[N], t2[N], t3[N], t4[N]; int main() { ll T = read(); while (T--) { n = read(); m = read(); q = read(); for (ll i = 1; i <= n; i++) for (ll j = 1; j <= m; j++) a[i][j] = read(); for (ll i = 1; i <= n; i++) t1[i] = i; for (ll i = 1; i <= m; i++) t2[i] = i; memset(t3, 0, sizeof t3); memset(t4, 0, sizeof t4); while (q--) { ll op = read(), x = read(), y = read(); if (op == 1) { swap(t1[x], t1[y]); } if (op == 2) { swap(t2[x], t2[y]); } if (op == 3) { t3[t1[x]] += y; } if (op == 4) { t4[t2[x]] += y; } } for (ll i = 1; i <= n; i++) { for (ll j = 1; j < m; j++) printf("%I64d ", a[t1[i]][t2[j]] + t3[t1[i]] + t4[t2[j]]); ll j = m; printf("%I64d\n", a[t1[i]][t2[j]] + t3[t1[i]] + t4[t2[j]]); } } }