#include <bits/stdc++.h>
using std::swap;
struct o {
  int r, d, val;
} l[1001 * 1001];
inline int get(int x, int y) {
  int nw = 1, i;
  for (i = 0; i < y; i++) ++nw;
  for (i = 0; i < x; i++) nw = l[nw].d;
  return nw;
}
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return x;
}
int main() {
  int n = read(), m = read(), q = read(), p = 1, i, k;
  for (i = 1; i <= (n + 1) * (m + 1); i++) {
    if (i > m + 1 && (i - 1) % (m + 1) != 0) l[i].val = read();
    if (i % (m + 1) != 0) l[i].r = i + 1;
    if (i <= n * (m + 1)) l[i].d = i + m + 1;
  }
  for (k = 0; k < q; k++) {
    int x1 = read(), y1 = read(), x2 = read(), y2 = read(), h = read(),
        w = read(), h1 = get(x1 - 1, y1 - 1), h2 = get(x2 - 1, y2 - 1),
        w1 = l[h1].r, w2 = l[h2].r;
    h1 = l[h1].d, h2 = l[h2].d;
    int h3 = get(x1, y1 + (w - 1)), h4 = get(x2, y2 + (w - 1)),
        w3 = get(x1 + (h - 1), y1), w4 = get(x2 + (h - 1), y2);
    for (i = 0; i < h; i++)
      swap(l[h1].r, l[h2].r), h1 = l[h1].d, h2 = l[h2].d,
                              swap(l[h3].r, l[h4].r), h3 = l[h3].d,
                              h4 = l[h4].d;
    for (i = 0; i < w; i++)
      swap(l[w1].d, l[w2].d), w1 = l[w1].r, w2 = l[w2].r,
                              swap(l[w3].d, l[w4].d), w3 = l[w3].r,
                              w4 = l[w4].r;
  }
  for (i = 0; i < n; i++) {
    p = l[p].d;
    for (int j = 0, nw = l[p].r; j < m; ++j) {
      printf("%d ", l[nw].val);
      nw = l[nw].r;
    }
    putchar('\n');
  }
}
