#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, w = 0;
  char ch = getchar();
  while (!isdigit(ch)) w |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return w ? -x : x;
}
struct node {
  int l, r, up, down;
  int val;
} a[1005][1005];
int n, m, q, b[1005][1005], cnt;
inline int calc(int x, int y) { return x * (m + 3) + y; }
inline pair<int, int> re_calc(int p) {
  return make_pair(p / (m + 3), p % (m + 3));
}
inline pair<int, int> dfs(int x, int y, int xx, int yy) {
  if (xx) {
    pair<int, int> now = re_calc(a[x][y].down);
    return dfs(now.first, now.second, xx - 1, yy);
  }
  if (yy) {
    pair<int, int> now = re_calc(a[x][y].r);
    return dfs(now.first, now.second, xx, yy - 1);
  }
  return make_pair(x, y);
}
inline pair<int, int> dfs2(int x, int y, int xx, int yy) {
  if (yy) {
    pair<int, int> now = re_calc(a[x][y].r);
    return dfs2(now.first, now.second, xx, yy - 1);
  }
  if (xx) {
    pair<int, int> now = re_calc(a[x][y].down);
    return dfs2(now.first, now.second, xx - 1, yy);
  }
  return make_pair(x, y);
}
int main() {
  n = read();
  m = read();
  q = read();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      a[i][j].val = read();
    }
  }
  for (int i = 0; i <= n + 1; i++)
    a[i][0].r = calc(i, 1), a[i][n + 1].l = calc(i, n);
  for (int i = 0; i <= m + 1; i++)
    a[0][i].down = calc(1, i), a[n + 1][i].up = calc(n, i);
  for (int i = 0; i <= m; i++)
    a[0][i].r = calc(0, i + 1), a[n + 1][i].r = calc(n + 1, i + 1);
  for (int i = 1; i <= m + 1; i++)
    a[0][i].l = calc(0, i - 1), a[n + 1][i].l = calc(n + 1, i - 1);
  for (int i = 0; i <= n; i++)
    a[i][0].down = calc(i + 1, 0), a[i][n + 1].down = calc(i + 1, n + 1);
  for (int i = 1; i <= n + 1; i++)
    a[i][0].up = calc(i - 1, 0), a[i][n + 1].up = calc(i - 1, n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      a[i][j].l = calc(i, j - 1);
      a[i][j].r = calc(i, j + 1);
      a[i][j].up = calc(i - 1, j);
      a[i][j].down = calc(i + 1, j);
    }
  }
  for (int i = 1; i <= q; i++) {
    int x1 = read(), y1 = read(), x2 = read(), y2 = read(), h = read(),
        w = read();
    pair<int, int> now1 = dfs(0, 0, x1 - 1, y1);
    pair<int, int> now2 = dfs(0, 0, x2 - 1, y2);
    pair<int, int> now3 = dfs(0, 0, x1 - 1, y1 + w - 1);
    pair<int, int> now4 = dfs(0, 0, x2 - 1, y2 + w - 1);
    for (int j = 0; j < h; j++) {
      now1 = dfs(now1.first, now1.second, 1, 0);
      now2 = dfs(now2.first, now2.second, 1, 0);
      now3 = dfs(now3.first, now3.second, 1, 0);
      now4 = dfs(now4.first, now4.second, 1, 0);
      pair<int, int> u = re_calc(a[now1.first][now1.second].l);
      pair<int, int> v = re_calc(a[now2.first][now2.second].l);
      a[u.first][u.second].r = calc(now2.first, now2.second);
      a[v.first][v.second].r = calc(now1.first, now1.second);
      a[now1.first][now1.second].l = calc(v.first, v.second);
      a[now2.first][now2.second].l = calc(u.first, u.second);
      u = re_calc(a[now3.first][now3.second].r);
      v = re_calc(a[now4.first][now4.second].r);
      a[u.first][u.second].l = calc(now4.first, now4.second);
      a[v.first][v.second].l = calc(now3.first, now3.second);
      a[now3.first][now3.second].r = calc(v.first, v.second);
      a[now4.first][now4.second].r = calc(u.first, u.second);
    }
    now1 = dfs2(0, 0, x1, y1 - 1);
    now2 = dfs2(0, 0, x2, y2 - 1);
    now3 = dfs2(0, 0, x1 + h - 1, y1 - 1);
    now4 = dfs2(0, 0, x2 + h - 1, y2 - 1);
    for (int j = 0; j < w; j++) {
      now1 = dfs(now1.first, now1.second, 0, 1);
      now2 = dfs(now2.first, now2.second, 0, 1);
      now3 = dfs(now3.first, now3.second, 0, 1);
      now4 = dfs(now4.first, now4.second, 0, 1);
      pair<int, int> u = re_calc(a[now1.first][now1.second].up);
      pair<int, int> v = re_calc(a[now2.first][now2.second].up);
      a[u.first][u.second].down = calc(now2.first, now2.second);
      a[v.first][v.second].down = calc(now1.first, now1.second);
      a[now1.first][now1.second].up = calc(v.first, v.second);
      a[now2.first][now2.second].up = calc(u.first, u.second);
      u = re_calc(a[now3.first][now3.second].down);
      v = re_calc(a[now4.first][now4.second].down);
      a[u.first][u.second].up = calc(now4.first, now4.second);
      a[v.first][v.second].up = calc(now3.first, now3.second);
      a[now3.first][now3.second].down = calc(v.first, v.second);
      a[now4.first][now4.second].down = calc(u.first, u.second);
    }
  }
  for (int i = 1; i <= n; i++) {
    pair<int, int> now = dfs(0, 0, i, 0);
    for (int j = 1; j <= m; j++) {
      now = dfs(now.first, now.second, 0, 1);
      printf("%d ", a[now.first][now.second].val);
    }
    printf("\n");
  }
  return 0;
}
