#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m, mat[N][N], q;
struct Value {
  Value *up, *down, *left, *right;
  int v;
  Value(int x) {
    up = down = left = right = NULL;
    v = x;
  }
} * root[N], *Upx[N], *Upy[N], *Downx[N], *Downy[N], *Leftx[N], *Lefty[N],
    *Rightx[N], *Righty[N];
inline void Initialize() {
  for (int i = 1; i <= n; i++) {
    Value *tp;
    for (int j = 1; j <= m; j++) {
      if (j == 1) {
        root[i] = new Value(mat[i][j]);
        tp = root[i];
      } else {
        tp->right = new Value(mat[i][j]);
        tp->right->left = tp;
        tp = tp->right;
      }
    }
  }
}
inline void Build() {
  Value *tp[N];
  tp[0] = tp[n + 1] = NULL;
  for (int i = 1; i <= n; i++) tp[i] = root[i];
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      tp[j]->up = tp[j - 1];
      tp[j]->down = tp[j + 1];
    }
    for (int j = 1; j <= n; j++) tp[j] = tp[j]->right;
  }
}
inline void SelectX(Value *r[N], int x, int y, int len) {
  Value *tp = root[x];
  for (int i = 1; i < y; i++) tp = tp->right;
  for (int i = 1; i <= len; i++) {
    r[i] = tp;
    tp = tp->right;
  }
}
inline void SelectY(Value *r[N], int x, int y, int len) {
  Value *tp = root[x];
  for (int i = 1; i < y; i++) tp = tp->right;
  for (int i = 1; i <= len; i++) {
    r[i] = tp;
    tp = tp->down;
  }
}
inline void PrintMatrix() {
  for (int i = 1; i <= n; i++) {
    Value *cur;
    for (int j = 1; j <= m; j++) {
      if (j == 1)
        cur = root[i];
      else
        cur = cur->right;
      printf("%d ", cur->v);
    }
    putchar('\n');
  }
}
inline void Change(int l1, int r1, int l2, int r2, int h, int w) {
  Value *tp;
  SelectX(Upx, l1, r1, w);
  SelectX(Upy, l2, r2, w);
  SelectX(Downx, l1 + h - 1, r1, w);
  SelectX(Downy, l2 + h - 1, r2, w);
  SelectY(Leftx, l1, r1, h);
  SelectY(Lefty, l2, r2, h);
  SelectY(Rightx, l1, r1 + w - 1, h);
  SelectY(Righty, l2, r2 + w - 1, h);
  for (int i = 1; i <= h; i++) {
    if (Leftx[i]->left && Lefty[i]->left) {
      Leftx[i]->left->right = Lefty[i];
      Lefty[i]->left->right = Leftx[i];
      tp = Leftx[i]->left;
      Leftx[i]->left = Lefty[i]->left;
      Lefty[i]->left = tp;
    } else if (Leftx[i]->left && !Lefty[i]->left) {
      Lefty[i]->left = Leftx[i]->left;
      Leftx[i]->left->right = Lefty[i];
      Leftx[i]->left = NULL;
      root[l2 + i - 1] = Leftx[i];
    } else if (!Leftx[i]->left && Lefty[i]->left) {
      Leftx[i]->left = Lefty[i]->left;
      Lefty[i]->left->right = Leftx[i];
      Lefty[i]->left = NULL;
      root[l1 + i - 1] = Lefty[i];
    } else if (!Leftx[i]->left && !Lefty[i]->left) {
      root[l1 + i - 1] = Lefty[i];
      root[l2 + i - 1] = Leftx[i];
    }
    if (Rightx[i]->right && Righty[i]->right) {
      Rightx[i]->right->left = Righty[i];
      Righty[i]->right->left = Rightx[i];
      tp = Rightx[i]->right;
      Rightx[i]->right = Righty[i]->right;
      Righty[i]->right = tp;
    } else if (Rightx[i]->right && !Righty[i]->right) {
      Righty[i]->right = Rightx[i]->right;
      Rightx[i]->right->left = Righty[i];
      Rightx[i]->right = NULL;
    } else if (!Rightx[i]->right && Righty[i]->right) {
      Rightx[i]->right = Righty[i]->right;
      Righty[i]->right->left = Rightx[i];
      Righty[i]->right = NULL;
    }
  }
  for (int i = 1; i <= w; i++) {
    if (Upx[i]->up && Upy[i]->up) {
      Upx[i]->up->down = Upy[i];
      Upy[i]->up->down = Upx[i];
      tp = Upx[i]->up;
      Upx[i]->up = Upy[i]->up;
      Upy[i]->up = tp;
    } else if (Upx[i]->up && !Upy[i]->up) {
      Upx[i]->up->down = Upy[i];
      Upy[i]->up = Upx[i]->up;
      Upx[i]->up = NULL;
    } else if (!Upx[i]->up && Upy[i]->up) {
      Upx[i]->up = Upy[i]->up;
      Upy[i]->up->down = Upx[i];
      Upy[i]->up = NULL;
    }
    if (Downx[i]->down && Downy[i]->down) {
      Downx[i]->down->up = Downy[i];
      Downy[i]->down->up = Downx[i];
      tp = Downx[i]->down;
      Downx[i]->down = Downy[i]->down;
      Downy[i]->down = tp;
    } else if (Downx[i]->down && !Downy[i]->down) {
      Downy[i]->down = Downx[i]->down;
      Downx[i]->down->up = Downy[i];
      Downx[i]->down = NULL;
    } else if (!Downx[i]->down && Downy[i]->down) {
      Downx[i]->down = Downy[i]->down;
      Downy[i]->down->up = Downx[i];
      Downy[i]->down = NULL;
    }
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &mat[i][j]);
  Initialize();
  Build();
  while (q--) {
    int l1, r1, l2, r2, h, w;
    scanf("%d %d %d %d %d %d", &l1, &r1, &l2, &r2, &h, &w);
    Change(l1, r1, l2, r2, h, w);
  }
  PrintMatrix();
  return 0;
}
