#include <bits/stdc++.h>
using namespace std;
inline int Mul(int x, int y) { return 1ll * x * y % 1000000007; }
inline int Add(int x, int y) {
  return ((x + y) % 1000000007 + 1000000007) % 1000000007;
}
int n, m, Q, tot;
int v[1010 * 1010], id[1010][1010];
int up[1010 * 1010], down[1010 * 1010], l[1010 * 1010], r[1010 * 1010];
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) {
      id[i][j] = ++tot;
      if (i && i <= n && j && j <= m) scanf("%d", &v[tot]);
    }
  }
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) {
      if (i) up[id[i][j]] = id[i - 1][j];
      if (i <= n) down[id[i][j]] = id[i + 1][j];
      if (j) l[id[i][j]] = id[i][j - 1];
      if (j <= m) r[id[i][j]] = id[i][j + 1];
    }
  }
  int x1, y1, x2, y2, h, w, x, y;
  while (Q--) {
    scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &h, &w);
    x = id[x1][0];
    for (int i = 1; i <= y1; i++) x = r[x];
    y = id[x2][0];
    for (int i = 1; i <= y2; i++) y = r[y];
    for (int j = 1; j <= w; j++) {
      down[up[x]] = y;
      down[up[y]] = x;
      swap(up[x], up[y]);
      x = r[x], y = r[y];
    }
    x = l[x], y = l[y];
    for (int j = 1; j <= h; j++) {
      l[r[x]] = y;
      l[r[y]] = x;
      swap(r[x], r[y]);
      x = down[x], y = down[y];
    }
    x = up[x], y = up[y];
    for (int j = 1; j <= w; j++) {
      up[down[x]] = y;
      up[down[y]] = x;
      swap(down[x], down[y]);
      x = l[x], y = l[y];
    }
    x = r[x], y = r[y];
    for (int j = 1; j <= h; j++) {
      r[l[x]] = y;
      r[l[y]] = x;
      swap(l[x], l[y]);
      x = up[x], y = up[y];
    }
  }
  for (int i = 1; i <= n; i++) {
    x = id[i][0];
    for (int j = 1; j <= m; j++) {
      x = r[x];
      printf("%d%c", v[x], j == m ? '\n' : ' ');
    }
  }
  return 0;
}
