#include <bits/stdc++.h>
inline void write(int a) {
  using std::putchar;
  char d[10];
  int sz(0);
  do {
    d[sz++] = a % 10 + '0';
    a /= 10;
  } while (a);
  for (; sz; --sz) putchar(d[sz - 1]);
  putchar(' ');
}
inline void read(int &a) {
  using std::getchar;
  a = 0;
  char c;
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) a = a * 10 + c - '0';
}
template <typename T>
void swap(T &a, T &b) {
  T c = a;
  a = b;
  b = c;
}
struct node {
  node *D, *R;
  int data;
  node(int dt) {
    data = dt;
    D = R = NULL;
  }
};
inline void down(node **P) { *P = (*P)->D; }
inline void right(node **P) { *P = (*P)->R; }
inline void put(node **P, int i, int j) {
  for (int cnt(1); cnt < i; ++cnt) down(P);
  for (int cnt(1); cnt < j; ++cnt) right(P);
}
int main() {
  int n, m, q, in, cnt;
  read(n);
  read(m);
  read(q);
  node *root = new node(-1), *p;
  for (cnt = 1, p = root; cnt <= n; ++cnt) {
    p->D = new node(-1);
    down(&p);
  }
  for (cnt = 1, p = root; cnt <= m; ++cnt) {
    p->R = new node(-1);
    right(&p);
  }
  node *i, *j, *k;
  int cnt_i, cnt_j;
  for (i = root, cnt_i = 0; cnt_i < n; ++cnt_i, down(&i))
    for (j = i->R, k = i->D, cnt_j = 1; cnt_j <= m;
         ++cnt_j, right(&j), right(&k)) {
      read(in);
      j->D = new node(in);
      k->R = j->D;
    }
  int a, b, c, d, h, w;
  node *ps1, *ps2, *us1, *ds1, *ls1, *rs1, *us2, *ds2, *ls2, *rs2;
  while (q--) {
    read(a);
    read(b);
    read(c);
    read(d);
    read(h);
    read(w);
    ps1 = root;
    ps2 = root;
    put(&ps1, a, b);
    put(&ps2, c, d);
    us1 = ps1->R;
    us2 = ps2->R;
    ls1 = ps1->D;
    ls2 = ps2->D;
    ds1 = ps1->D->R;
    put(&ds1, h, 0);
    ds2 = ps2->D->R;
    put(&ds2, h, 0);
    rs1 = ps1->D->R;
    put(&rs1, 0, w);
    rs2 = ps2->D->R;
    put(&rs2, 0, w);
    for (int cnt(0); cnt < h;
         ++cnt, down(&ls1), down(&ls2), down(&rs1), down(&rs2)) {
      swap(ls1->R, ls2->R);
      swap(rs1->R, rs2->R);
    }
    for (int cnt(0); cnt < w;
         ++cnt, right(&us1), right(&us2), right(&ds1), right(&ds2)) {
      swap(us1->D, us2->D);
      swap(ds1->D, ds2->D);
    }
  }
  for (cnt_i = 1, i = root->D; cnt_i <= n; ++cnt_i, down(&i)) {
    for (cnt_j = 1, j = i->R; cnt_j <= m; ++cnt_j, right(&j)) write(j->data);
    std::putchar('\n');
  }
}
