#include <bits/stdc++.h>
using namespace std;
int val[1005][1005];
struct Node {
  int val;
  Node *l, *r, *u, *d;
  Node() { l = r = u = d = 0; }
} * nodes[1005 * 1005];
int n, m;
inline int Cod(int x, int y) { return x * (m + 2) + (y + 1); }
inline bool Ok(int x, int y) {
  if (x < 0 || x > n + 1 || y < 0 || y > m + 1) return false;
  return true;
}
inline Node *Find(int x, int y) {
  Node *sol = nodes[Cod(x, 0)];
  for (int i = 1; i <= y; ++i) sol = sol->r;
  return sol;
}
inline void Show() {
  Node *nod = nodes[2], *nod1;
  int i, j;
  for (i = 1; i <= n; ++i) {
    nod = nod->d;
    for (nod1 = nod, j = 1; j <= m; ++j, nod1 = nod1->r)
      printf("%d ", nod1->val);
    printf("\n");
  }
}
int main() {
  int i, j, i1, j1, q;
  int x1, y1, x2, y2, L, C;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) scanf("%d", &val[i][j]);
  for (i = 0; i <= n + 1; ++i)
    for (j = 0; j <= m + 1; ++j) {
      int code = Cod(i, j);
      nodes[code] = new Node();
      nodes[code]->val = val[i][j];
    }
  for (i = 0; i <= n + 1; ++i)
    for (j = 0; j <= m + 1; ++j) {
      int code = Cod(i, j);
      if (Ok(i - 1, j)) nodes[code]->u = nodes[Cod(i - 1, j)];
      if (Ok(i, j + 1)) nodes[code]->r = nodes[Cod(i, j + 1)];
      if (Ok(i + 1, j)) nodes[code]->d = nodes[Cod(i + 1, j)];
      if (Ok(i, j - 1)) nodes[code]->l = nodes[Cod(i, j - 1)];
    }
  while (q--) {
    cin >> x1 >> y1 >> x2 >> y2 >> C >> L;
    Node *n1 = Find(x1, y1);
    Node *n2 = Find(x2, y2);
    for (i = 0; i < L; ++i) {
      Node *cn1u = n1->u;
      n1->u = n2->u;
      n2->u->d = n1;
      n2->u = cn1u;
      cn1u->d = n2;
      n1 = n1->r;
      n2 = n2->r;
    }
    n1 = n1->l;
    n2 = n2->l;
    for (i = 0; i < C; ++i) {
      Node *cn1r = n1->r;
      n1->r = n2->r;
      n2->r->l = n1;
      n2->r = cn1r;
      cn1r->l = n2;
      n1 = n1->d;
      n2 = n2->d;
    }
    n1 = n1->u;
    n2 = n2->u;
    for (i = 0; i < L; ++i) {
      Node *cn1d = n1->d;
      n1->d = n2->d;
      n2->d->u = n1;
      n2->d = cn1d;
      cn1d->u = n2;
      n1 = n1->l;
      n2 = n2->l;
    }
    n1 = n1->r;
    n2 = n2->r;
    for (i = 0; i < C; ++i) {
      Node *cn1l = n1->l;
      n1->l = n2->l;
      n2->l->r = n1;
      n2->l = cn1l;
      cn1l->r = n2;
      n1 = n1->u;
      n2 = n2->u;
    }
  }
  Show();
  return 0;
}
