#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
struct node {
  node *up, *dn, *lt, *rt;
  int v;
  int x, y;
};
void setup(node *n, node *t) {
  if (t == NULL) {
    n->up->dn = NULL;
    n->up = NULL;
  } else {
    n->up = t;
    t->dn = n;
  }
}
void setdn(node *n, node *t) {
  if (t == NULL) {
    n->dn->up = NULL;
    n->dn = NULL;
  } else {
    n->dn = t;
    t->up = n;
  }
}
void setlt(node *n, node *t) {
  if (t == NULL) {
    n->lt->rt = NULL;
    n->lt = NULL;
  } else {
    n->lt = t;
    t->rt = n;
  }
}
void setrt(node *n, node *t) {
  if (t == NULL) {
    n->rt->lt = NULL;
    n->rt = NULL;
  } else {
    n->rt = t;
    t->lt = n;
  }
}
int N, M, Q;
node A[MAXN][MAXN];
node *at(int x, int y) {
  node *n = A[0];
  for (int i = 0; i < x; i++) {
    n = n->dn;
  }
  for (int j = 0; j < y; j++) {
    n = n->rt;
  }
  return n;
}
pair<node *, vector<node *> > cut(int a, int b, int h, int w) {
  node *ab = at(a, b);
  vector<node *> ans;
  for (int i = 0; i < h; i++) {
    ans.push_back(ab->lt);
    if (i != h - 1) {
      ab = ab->dn;
    }
  }
  for (int j = 0; j < w; j++) {
    ans.push_back(ab->dn);
    if (j != w - 1) {
      ab = ab->rt;
    }
  }
  for (int i = 0; i < h; i++) {
    ans.push_back(ab->rt);
    if (i != h - 1) {
      ab = ab->up;
    }
  }
  for (int j = 0; j < w; j++) {
    ans.push_back(ab->up);
    if (j != w - 1) {
      ab = ab->lt;
    }
  }
  return make_pair(ab, ans);
}
void link(node *n, vector<node *> v, int h, int w) {
  int ptr = 0;
  for (int i = 0; i < h; i++) {
    setlt(n, v[ptr++]);
    if (i != h - 1) {
      n = n->dn;
    }
  }
  for (int j = 0; j < w; j++) {
    setdn(n, v[ptr++]);
    if (j != w - 1) {
      n = n->rt;
    }
  }
  for (int i = 0; i < h; i++) {
    setrt(n, v[ptr++]);
    if (i != h - 1) {
      n = n->up;
    }
  }
  for (int j = 0; j < w; j++) {
    setup(n, v[ptr++]);
    if (j != w - 1) {
      n = n->lt;
    }
  }
}
int main() {
  scanf("%d %d %d", &N, &M, &Q);
  for (int i = 0; i <= N + 1; i++) {
    for (int j = 0; j <= M + 1; j++) {
      A[i][j].x = i;
      A[i][j].y = j;
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      scanf("%d", &A[i][j].v);
    }
  }
  for (int i = 0; i <= N + 1; i++) {
    for (int j = 0; j <= M; j++) {
      setrt(A[i] + j, A[i] + j + 1);
    }
  }
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M + 1; j++) {
      setdn(A[i] + j, A[i + 1] + j);
    }
  }
  while (Q--) {
    int a, b, c, d, h, w;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &h, &w);
    auto nab = cut(a, b, h, w);
    auto ncd = cut(c, d, h, w);
    link(nab.first, ncd.second, h, w);
    link(ncd.first, nab.second, h, w);
  }
  node *n = A[0];
  for (int i = 1; i <= N; i++) {
    n = n->dn;
    node *nj = n;
    for (int j = 1; j <= M; j++) {
      nj = nj->rt;
      printf("%d ", nj->v);
    }
    puts("");
  }
}
