#include <bits/stdc++.h>
using namespace std;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline long long inc(int &x) { return ++x; }
inline long long inc(long long &x) { return ++x; }
inline long long inc(int &x, long long y) { return x += y; }
inline long long inc(long long &x, long long y) { return x += y; }
inline double inc(double &x, double y) { return x += y; }
inline long long dec(int &x) { return --x; }
inline long long dec(long long &x) { return --x; }
inline long long dec(int &x, long long y) { return x -= y; }
inline long long dec(long long &x, long long y) { return x -= y; }
inline double dec(double &x, double y) { return x -= y; }
inline long long mul(int &x) { return x = ((long long)x) * x; }
inline long long mul(long long &x) { return x = x * x; }
inline long long mul(int &x, long long y) { return x *= y; }
inline long long mul(long long &x, long long y) { return x *= y; }
inline double mul(double &x, double y) { return x *= y; }
inline long long divi(int &x) { return x = sqrt(x); }
inline long long divi(long long &x) { return x = sqrt(x); }
inline long long divi(int &x, long long y) { return x /= y; }
inline long long divi(long long &x, long long y) { return x /= y; }
inline double divi(double &x, double y) { return x /= y; }
inline long long mod(int &x, long long y) { return x %= y; }
inline long long mod(long long &x, long long y) { return x %= y; }
int n, m, q, i, j, x, y, xx, yy, lx, ly, cnt, tmp[1111][1111];
struct nd {
  int r, d, x, y, key;
} a[1111 * 1111];
inline int getxy(int x, int y) { return x * (m + 1) + y; }
int find(int x, int y) {
  int t = 0, i;
  if ((1) <= ((x)))
    for (((i)) = (1); ((i)) <= ((x)); ((i))++) t = a[t].d;
  if ((1) <= ((y)))
    for (((i)) = (1); ((i)) <= ((y)); ((i))++) t = a[t].r;
  return t;
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin >> n >> m >> q;
  if ((0) <= (n))
    for ((i) = (0); (i) <= (n); (i)++)
      if ((0) <= (m))
        for ((j) = (0); (j) <= (m); (j)++) {
          if (i && j) cin >> tmp[i][j];
          a[getxy(i, j)].x = i;
          a[getxy(i, j)].y = j;
          a[getxy(i, j)].key = tmp[i][j];
          a[getxy(i, j)].d = getxy(i + 1, j);
          a[getxy(i, j)].r = getxy(i, j + 1);
        }
  if ((1) <= ((q)))
    for (((j)) = (1); ((j)) <= ((q)); ((j))++) {
      cin >> x >> y >> xx >> yy >> lx >> ly;
      int t1 = find(x - 1, y - 1), t2 = find(xx - 1, yy - 1);
      int t3 = t1, t4 = t2;
      if ((1) <= ((lx)))
        for (((i)) = (1); ((i)) <= ((lx)); ((i))++) {
          t3 = a[t3].d;
          t4 = a[t4].d;
          swap(a[t3].r, a[t4].r);
        }
      if ((1) <= ((ly)))
        for (((i)) = (1); ((i)) <= ((ly)); ((i))++) {
          t3 = a[t3].r;
          t4 = a[t4].r;
          swap(a[t3].d, a[t4].d);
        }
      t3 = t1;
      t4 = t2;
      if ((1) <= ((ly)))
        for (((i)) = (1); ((i)) <= ((ly)); ((i))++) {
          t3 = a[t3].r;
          t4 = a[t4].r;
          swap(a[t3].d, a[t4].d);
        }
      if ((1) <= ((lx)))
        for (((i)) = (1); ((i)) <= ((lx)); ((i))++) {
          t3 = a[t3].d;
          t4 = a[t4].d;
          swap(a[t3].r, a[t4].r);
        }
    }
  int pos = find(1, 1);
  if ((1) <= ((n)))
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
      int t = pos;
      if ((1) <= ((m)))
        for (((j)) = (1); ((j)) <= ((m)); ((j))++) {
          cout << a[t].key << ' ';
          t = a[t].r;
        }
      cout << endl;
      pos = a[pos].d;
    }
  return 0;
}
