#include #include #include #include using namespace std; typedef long long i64; const int N = 1e3 + 10; struct Data { int ord[N]; i64 sum[N]; }; Data X, Y; i64 x[N], y[N], a[N][N]; int main() { int tcase; scanf("%d", &tcase); while (tcase--) { int n, m, q; scanf("%d%d%d", &n, &m, &q); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) scanf("%I64d", &a[i][j]); for (int i = 1; i <= n; ++i) { X.ord[i] = i; X.sum[i] = 0; } for (int i = 1; i <= m; ++i) { Y.ord[i] = i; Y.sum[i] = 0; } for (int i = 1; i <= q; ++i) { int t, x, y; scanf("%d%d%d", &t, &x, &y); if (t == 1) { swap(X.ord[x], X.ord[y]); } else if (t == 2) { swap(Y.ord[x], Y.ord[y]); } else if (t == 3) { X.sum[X.ord[x]] += y; } else { Y.sum[Y.ord[x]] += y; } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { a[i][j] += X.sum[i]; a[i][j] += Y.sum[j]; } } for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { int x = X.ord[i], y = Y.ord[j]; if (j < m) printf("%I64d ", a[x][y]); else printf("%I64d\n", a[x][y]); } } return 0; }