#include <bits/stdc++.h>
using namespace std;
template <class T, class L>
bool smax(T &x, L y) {
  return x < y ? (x = y, 1) : 0;
}
template <class T, class L>
bool smin(T &x, L y) {
  return y < x ? (x = y, 1) : 0;
}
const int maxn = 1e3 + 17;
int n, m, q;
struct node {
  node *d, *r;
  int val;
} a[maxn][maxn];
node *get(int x, int y) {
  node *ret = &a[0][0];
  while (x--) ret = ret->d;
  while (y--) ret = ret->r;
  return ret;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j].val;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      a[i][j].d = &a[i + 1][j], a[i][j].r = &a[i][j + 1];
  for (int fx, fy, tx, ty, hi, wi; q--;) {
    cin >> fx >> fy >> tx >> ty >> hi >> wi;
    node *fru = get(fx - 1, fy), *tru = get(tx - 1, ty),
         *frd = get(fx + hi - 1, fy), *trd = get(tx + hi - 1, ty);
    node *flu = get(fx, fy - 1), *tlu = get(tx, ty - 1),
         *fld = get(fx, fy + wi - 1), *tld = get(tx, ty + wi - 1);
    while (wi--) {
      swap(fru->d, tru->d), fru = fru->r, tru = tru->r;
      swap(frd->d, trd->d), frd = frd->r, trd = trd->r;
    }
    while (hi--) {
      swap(flu->r, tlu->r), flu = flu->d, tlu = tlu->d;
      swap(fld->r, tld->r), fld = fld->d, tld = tld->d;
    }
  }
  for (int i = 1; i <= n; i++) {
    node *st = get(i, 1);
    for (int j = 1; j <= m; j++) cout << st->val << ' ', st = st->r;
    cout << '\n';
  }
  return 0;
}
