#include <iostream>
using namespace std;
const int MAX_SIZE = 10;
int main() {
int n, m, q, mt[MAX_SIZE + 1][MAX_SIZE + 1];
cin >> n >> m >> q;
for (int line = 1; line <= n; ++line) {
for (int col = 1; col <= m; ++col) {
cin >> mt[line][col];
}
}
int k, i, j, u, v;
for (int line = 1; line <= q; ++line) {
cin >> k >> i >> j;
if (k == 1) {
int x;
cin >> x;
mt[i][j] = x;
} else {
int u, v;
cin >> u >> v;
mt[i][j] = mt[u][v];
}
}
for (int line = 1; line <= n; ++line) {
for (int col = 1; col <= m; ++col) {
cout << mt[line][col] << " ";
}
cout << "\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gMTA7CgppbnQgbWFpbigpIHsKICAgIGludCBuLCBtLCBxLCBtdFtNQVhfU0laRSArIDFdW01BWF9TSVpFICsgMV07CiAgICBjaW4gPj4gbiA+PiBtID4+IHE7CiAgICBmb3IgKGludCBsaW5lID0gMTsgbGluZSA8PSBuOyArK2xpbmUpIHsKICAgICAgICBmb3IgKGludCBjb2wgPSAxOyBjb2wgPD0gbTsgKytjb2wpIHsKICAgICAgICAgICAgY2luID4+IG10W2xpbmVdW2NvbF07CiAgICAgICAgfQogICAgfQogICAgaW50IGssIGksIGosIHUsIHY7CiAgICBmb3IgKGludCBsaW5lID0gMTsgbGluZSA8PSBxOyArK2xpbmUpIHsKICAgICAgICBjaW4gPj4gayA+PiBpID4+IGo7CiAgICAgICAgaWYgKGsgPT0gMSkgewogICAgICAgICAgICBpbnQgeDsKICAgICAgICAgICAgY2luID4+IHg7CiAgICAgICAgICAgIG10W2ldW2pdID0geDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpbnQgdSwgdjsKICAgICAgICAgICAgY2luID4+IHUgPj4gdjsKICAgICAgICAgICAgbXRbaV1bal0gPSBtdFt1XVt2XTsKICAgICAgICB9CiAgICB9CiAgICBmb3IgKGludCBsaW5lID0gMTsgbGluZSA8PSBuOyArK2xpbmUpIHsKICAgICAgICBmb3IgKGludCBjb2wgPSAxOyBjb2wgPD0gbTsgKytjb2wpIHsKICAgICAgICAgICAgY291dCA8PCBtdFtsaW5lXVtjb2xdIDw8ICIgIjsKICAgICAgICB9CiAgICAgICAgY291dCA8PCAiXG4iOwogICAgfQogICAgcmV0dXJuIDA7Cn0=