#include <bits/stdc++.h>
using namespace std;
struct RD {
  int ri, rj, di, dj, val;
} a[1001][1001];
int n, m, t, T, lx, ly, rx, ry, hi, wi;
int Ix, Iy, Jx, Jy, Ix2, Jx2, Iy2, Jy2;
int main() {
  scanf("%d%d%d", &n, &m, &T);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j].val);
      a[i][j].di = i + 1;
      a[i][j].dj = j;
      a[i][j].ri = i;
      a[i][j].rj = j + 1;
    }
  for (int i = 1; i <= m; i++)
    a[0][i].di = 1, a[0][i].dj = i, a[0][i].ri = 0, a[0][i].rj = i + 1;
  for (int i = 1; i <= n; i++)
    a[i][0].ri = i, a[i][0].rj = 1, a[i][0].di = i + 1, a[i][0].dj = 0;
  while (T--) {
    scanf("%d%d%d%d%d%d", &lx, &ly, &rx, &ry, &hi, &wi);
    Ix = lx, Jx = 0;
    for (int i = 1; i <= ly - 1; i++) {
      t = a[Ix][Jx].ri;
      Jx = a[Ix][Jx].rj;
      Ix = t;
    }
    Iy = rx, Jy = 0;
    for (int i = 1; i <= ry - 1; i++) {
      t = a[Iy][Jy].ri;
      Jy = a[Iy][Jy].rj;
      Iy = t;
    }
    Ix2 = Ix, Jx2 = Jx;
    for (int i = 1; i <= wi; i++) {
      t = a[Ix][Jx].ri;
      Jx = a[Ix][Jx].rj;
      Ix = t;
    }
    Iy2 = Iy, Jy2 = Jy;
    for (int i = 1; i <= wi; i++) {
      t = a[Iy][Jy].ri;
      Jy = a[Iy][Jy].rj;
      Iy = t;
    }
    for (int i = 1; i <= hi; i++) {
      swap(a[Ix][Jx].ri, a[Iy][Jy].ri);
      swap(a[Ix][Jx].rj, a[Iy][Jy].rj);
      t = a[Ix][Jx].di;
      Jx = a[Ix][Jx].dj;
      Ix = t;
      t = a[Iy][Jy].di;
      Jy = a[Iy][Jy].dj;
      Iy = t;
      swap(a[Ix2][Jx2].ri, a[Iy2][Jy2].ri);
      swap(a[Ix2][Jx2].rj, a[Iy2][Jy2].rj);
      t = a[Ix2][Jx2].di;
      Jx2 = a[Ix2][Jx2].dj;
      Ix2 = t;
      t = a[Iy2][Jy2].di;
      Jy2 = a[Iy2][Jy2].dj;
      Iy2 = t;
    }
    Ix = 0, Jx = ly;
    for (int i = 1; i <= lx - 1; i++) {
      t = a[Ix][Jx].di;
      Jx = a[Ix][Jx].dj;
      Ix = t;
    }
    Iy = 0, Jy = ry;
    for (int i = 1; i <= rx - 1; i++) {
      t = a[Iy][Jy].di;
      Jy = a[Iy][Jy].dj;
      Iy = t;
    }
    Ix2 = Ix, Jx2 = Jx;
    for (int i = 1; i <= hi; i++) {
      t = a[Ix][Jx].di;
      Jx = a[Ix][Jx].dj;
      Ix = t;
    }
    Iy2 = Iy, Jy2 = Jy;
    for (int i = 1; i <= hi; i++) {
      t = a[Iy][Jy].di;
      Jy = a[Iy][Jy].dj;
      Iy = t;
    }
    for (int i = 1; i <= wi; i++) {
      swap(a[Ix][Jx].di, a[Iy][Jy].di);
      swap(a[Ix][Jx].dj, a[Iy][Jy].dj);
      t = a[Ix][Jx].ri;
      Jx = a[Ix][Jx].rj;
      Ix = t;
      t = a[Iy][Jy].ri;
      Jy = a[Iy][Jy].rj;
      Iy = t;
      swap(a[Ix2][Jx2].di, a[Iy2][Jy2].di);
      swap(a[Ix2][Jx2].dj, a[Iy2][Jy2].dj);
      t = a[Ix2][Jx2].ri;
      Jx2 = a[Ix2][Jx2].rj;
      Ix2 = t;
      t = a[Iy2][Jy2].ri;
      Jy2 = a[Iy2][Jy2].rj;
      Iy2 = t;
    }
  }
  for (int i = 1; i <= n; i++) {
    int I = i, J = 0;
    for (int j = 1; j <= m; j++) {
      t = a[I][J].ri;
      J = a[I][J].rj;
      I = t;
      printf("%d ", a[I][J].val);
    }
    puts("");
  }
}
