#include <bits/stdc++.h>
using namespace std;
struct A {
  int v;
  A* right;
  A* down;
} G[1111][1111];
int n, m, k;
int a, b, c, d, h, w;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &G[i][j].v);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) {
      G[i][j].right = &G[i][j + 1];
      G[i][j].down = &G[i + 1][j];
    }
  while (k--) {
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &h, &w);
    A* du[2] = {&G[a - 1][0], &G[c - 1][0]};
    A* dd[2] = {&G[a + h - 1][0], &G[c + h - 1][0]};
    for (int i = 1; i <= b; i++) {
      du[0] = du[0]->right;
      dd[0] = dd[0]->right;
    }
    for (int i = 1; i <= d; i++) {
      du[1] = du[1]->right;
      dd[1] = dd[1]->right;
    }
    A* dl[2] = {&G[0][b - 1], &G[0][d - 1]};
    A* dr[2] = {&G[0][b + w - 1], &G[0][d + w - 1]};
    for (int i = 1; i <= a; i++) {
      dl[0] = dl[0]->down;
      dr[0] = dr[0]->down;
    }
    for (int i = 1; i <= c; i++) {
      dl[1] = dl[1]->down;
      dr[1] = dr[1]->down;
    }
    for (int i = 1; i <= w; i++) {
      swap(du[0]->down, du[1]->down);
      swap(dd[0]->down, dd[1]->down);
      du[0] = du[0]->right;
      du[1] = du[1]->right;
      dd[0] = dd[0]->right;
      dd[1] = dd[1]->right;
    }
    for (int i = 1; i <= h; i++) {
      swap(dl[0]->right, dl[1]->right);
      swap(dr[0]->right, dr[1]->right);
      dl[0] = dl[0]->down;
      dl[1] = dl[1]->down;
      dr[0] = dr[0]->down;
      dr[1] = dr[1]->down;
    }
  }
  for (int i = 1; i <= n; i++, puts("")) {
    A* tmp = &G[i][0];
    for (int j = 1; j <= m; j++) {
      tmp = tmp->right;
      printf("%d ", tmp->v);
    }
  }
  return 0;
}
