#include <bits/stdc++.h>
using namespace std;
struct node {
  int val;
  int x;
  int y;
};
node tab[2000006];
int n, m, q;
int v;
int a, b, c, d, h, w;
void zamien() {
  int x1, y1, x2, y2;
  x1 = y1 = x2 = y2 = 0;
  int p1, p2;
  p1 = 0;
  p2 = 0;
  for (int i = 0; i < (a - 1); ++i) {
    p1 = tab[p1].y;
    y1++;
  }
  for (int i = 0; i < (b - 1); ++i) {
    x1++;
    p1 = tab[p1].x;
  }
  for (int i = 0; i < (c - 1); ++i) {
    p2 = tab[p2].y;
    y2++;
  }
  for (int i = 0; i < (d - 1); ++i) {
    p2 = tab[p2].x;
    x2++;
  }
  int xp1, xp2;
  xp1 = p1;
  xp2 = p2;
  for (int i = 0; i < (w); ++i) {
    xp1 = tab[xp1].x;
    xp2 = tab[xp2].x;
    swap(tab[xp2].y, tab[xp1].y);
  }
  int yp1, yp2;
  yp1 = p1;
  yp2 = p2;
  for (int i = 0; i < (h); ++i) {
    yp1 = tab[yp1].y;
    yp2 = tab[yp2].y;
    swap(tab[yp1].x, tab[yp2].x);
  }
  for (int i = 0; i < (w); ++i) {
    yp1 = tab[yp1].x;
    yp2 = tab[yp2].x;
    swap(tab[yp1].y, tab[yp2].y);
  }
  for (int i = 0; i < (h); ++i) {
    xp1 = tab[xp1].y;
    xp2 = tab[xp2].y;
    swap(tab[xp2].x, tab[xp1].x);
  }
}
int ans[1003][1003];
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= (n); ++i) {
    for (int p = 1; p <= (m); ++p) {
      scanf("%d", &tab[i * (m + 2) + p].val);
      tab[i * (m + 2) + p].x = i * (m + 2) + p + 1;
      tab[i * (m + 2) + p].y = (i + 1) * (m + 2) + p;
    }
  }
  for (int i = 0; i <= (m); ++i) {
    tab[i].x = i + 1;
    tab[i].y = m + 2 + i;
    tab[(n + 1) * (m + 2) + i].x = (n + 1) * (m + 2) + i + 1;
  }
  for (int i = 0; i <= (n); ++i) {
    tab[i * (m + 2)].y = (i + 1) * (m + 2);
    tab[i * (m + 2)].x = i * (m + 2) + 1;
    tab[(i + 1) * (m + 2) - 1].y = (i + 2) * (m + 2) - 1;
  }
  int p1, p2;
  for (int i = 0; i < (q); ++i) {
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &h, &w);
    zamien();
  }
  p1 = 0;
  p2 = 0;
  for (int i = 1; i <= (n); ++i) {
    p1 = tab[p1].y;
    p2 = p1;
    for (int p = 1; p <= (m); ++p) {
      p2 = tab[p2].x;
      ans[i][p] = tab[p2].val;
      printf("%d ", ans[i][p]);
    }
    printf("\n");
  }
}
