#include <bits/stdc++.h>
using namespace std;
struct Node {
  int left, right, up, down, value;
  Node() { left = right = up = down = value = -1; }
};
vector<Node> node;
int N;
int get(int i, int j) {
  int res = 0;
  for (int(ii) = (0); (ii) < (int)(i); ++(ii)) res = node[res].down;
  for (int(jj) = (0); (jj) < (int)(j); ++(jj)) res = node[res].right;
  return res;
}
int main() {
  int M, Q;
  vector<vector<int> > A;
  {
    cin >> N >> M >> Q;
    node = vector<Node>((N + 2) * (M + 2));
    A = vector<vector<int> >(N + 2, vector<int>(M + 2));
    for (int(i) = (1); (i) < (int)(N + 1); ++(i))
      for (int(j) = (1); (j) < (int)(M + 1); ++(j)) scanf("%d", &A[i][j]);
    for (int(i) = (0); (i) < (int)(N + 2); ++(i))
      for (int(j) = (0); (j) < (int)(M + 2); ++(j)) {
        int k = i * (M + 2) + j;
        node[k].value = A[i][j];
        if (i > 0) {
          int up = (i - 1) * (M + 2) + j;
          node[k].up = up;
          node[up].down = k;
        }
        if (j > 0) {
          int left = i * (M + 2) + (j - 1);
          node[k].left = left;
          node[left].right = k;
        }
      }
  }
  while (Q--) {
    int a, b, c, d, h, w;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &h, &w);
    int fi0 = get(a, b), se0 = get(c, d);
    int fi1 = get(a, b + w - 1), se1 = get(c, d + w - 1);
    int fi2 = get(a + h - 1, b), se2 = get(c + h - 1, d);
    {
      int fi = fi0, se = se0;
      for (int(i) = (0); (i) < (int)(h); ++(i)) {
        swap(node[node[fi].left].right, node[node[se].left].right);
        swap(node[fi].left, node[se].left);
        fi = node[fi].down;
        se = node[se].down;
      }
    }
    {
      int fi = fi1, se = se1;
      for (int(i) = (0); (i) < (int)(h); ++(i)) {
        swap(node[node[fi].right].left, node[node[se].right].left);
        swap(node[fi].right, node[se].right);
        fi = node[fi].down;
        se = node[se].down;
      }
    }
    {
      int fi = fi0, se = se0;
      for (int(i) = (0); (i) < (int)(w); ++(i)) {
        swap(node[node[fi].up].down, node[node[se].up].down);
        swap(node[fi].up, node[se].up);
        fi = node[fi].right;
        se = node[se].right;
      }
    }
    {
      int fi = fi2, se = se2;
      for (int(i) = (0); (i) < (int)(w); ++(i)) {
        swap(node[node[fi].down].up, node[node[se].down].up);
        swap(node[fi].down, node[se].down);
        fi = node[fi].right;
        se = node[se].right;
      }
    }
  }
  {
    int head = get(1, 1);
    for (int(i) = (0); (i) < (int)(N); ++(i)) {
      int cur = head;
      for (int(j) = (0); (j) < (int)(M); ++(j)) {
        printf("%d%c", node[cur].value, j != M - 1 ? ' ' : '\n');
        cur = node[cur].right;
      }
      head = node[head].down;
    }
  }
}
