#include <bits/stdc++.h>
using namespace std;
struct node {
  node *r, *d;
  int v;
  node() { d = r = NULL; }
} *root = new node;
node *find(int r, int c) {
  node *cur = root;
  for (int i = 0; i < r; i++) cur = cur->d;
  for (int j = 0; j < c; j++) cur = cur->r;
  return cur;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, queries;
  cin >> n >> m >> queries;
  node *curc = root, *curr = root, *prevc;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i > 0 && j > 0) cin >> curc->v;
      if (i > 0) {
        prevc->d = curc;
        prevc = prevc->r;
      }
      if (j < m) {
        curc->r = new node;
        curc = curc->r;
      }
    }
    if (i < n) {
      prevc = curr;
      curr = curc = new node;
    }
  }
  while (queries--) {
    int a, b, c, d, h, w;
    cin >> a >> b >> c >> d >> h >> w;
    node *up = find(a - 1, b), *lp = find(a, b - 1), *uq = find(c - 1, d),
         *lq = find(c, d - 1);
    for (int i = 1; i < h; i++) {
      swap(lp->r, lq->r);
      lp = lp->d;
      lq = lq->d;
    }
    node *tp = lp, *tq = lq;
    lp = lp->r;
    lq = lq->r;
    swap(tp->r, tq->r);
    for (int j = 1; j <= w; j++) {
      swap(lp->d, lq->d);
      lp = lp->r;
      lq = lq->r;
    }
    for (int j = 1; j < w; j++) {
      swap(up->d, uq->d);
      up = up->r;
      uq = uq->r;
    }
    tp = up, tq = uq;
    up = up->d;
    uq = uq->d;
    swap(tp->d, tq->d);
    for (int i = 1; i <= h; i++) {
      swap(up->r, uq->r);
      up = up->d;
      uq = uq->d;
    }
  }
  curc = curr = root->r->d;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << curc->v << ' ';
      curc = curc->r;
    }
    curc = curr = curr->d;
    cout << '\n';
  }
  return 0;
}
