#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 1;
const long long INF = 2e16 + 1;
const long long MOD = 1e9 + 7;
struct Cell {
  Cell *l, *d, *r, *u;
  int val;
  Cell() {}
  Cell(int val) : val(val), l(NULL), r(NULL), d(NULL), u(NULL) {}
  Cell(int val, Cell *l, Cell *d, Cell *r, Cell *u)
      : val(val), l(l), d(d), r(r), u(u) {}
};
Cell *cells[N][N];
int answer[N][N];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, q;
  cin >> n >> m >> q;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) {
      int x;
      cin >> x;
      cells[i][j] = new Cell(x);
    }
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) {
      if (j == 0)
        cells[i][j]->l = NULL;
      else
        cells[i][j]->l = cells[i][j - 1];
      if (i == n - 1)
        cells[i][j]->d = NULL;
      else
        cells[i][j]->d = cells[i + 1][j];
      if (j == m - 1)
        cells[i][j]->r = NULL;
      else
        cells[i][j]->r = cells[i][j + 1];
      if (i == 0)
        cells[i][j]->u = NULL;
      else
        cells[i][j]->u = cells[i - 1][j];
    }
  Cell *begcell = cells[0][0];
  for (long long i1 = 0; i1 < q; i1++) {
    int x1, y1, x2, y2, height, width;
    cin >> x1 >> y1 >> x2 >> y2 >> height >> width;
    Cell *cur1 = begcell;
    Cell *cur2 = begcell;
    if (x1 > x2 || x1 == x2 && y1 > y2) {
      swap(x1, x2);
      swap(y1, y2);
    }
    if (x1 == 1 && y1 == 1) {
      for (long long i = 0; i < x2 - 1; i++) begcell = begcell->d;
      for (long long i = 0; i < y2 - 1; i++) begcell = begcell->r;
    }
    for (long long i = 0; i < x1 - 1; i++) cur1 = cur1->d;
    for (long long i = 0; i < y1 - 1; i++) cur1 = cur1->r;
    for (long long i = 0; i < x2 - 1; i++) cur2 = cur2->d;
    for (long long i = 0; i < y2 - 1; i++) cur2 = cur2->r;
    for (long long i = 0; i < height; i++) {
      if (i) {
        cur1 = cur1->d;
        cur2 = cur2->d;
      }
      swap(cur1->l, cur2->l);
      if (cur1->l) cur1->l->r = cur1;
      if (cur2->l) cur2->l->r = cur2;
    }
    for (long long i = 0; i < width; i++) {
      if (i) {
        cur1 = cur1->r;
        cur2 = cur2->r;
      }
      swap(cur1->d, cur2->d);
      if (cur1->d) cur1->d->u = cur1;
      if (cur2->d) cur2->d->u = cur2;
    }
    for (long long i = 0; i < height; i++) {
      if (i) {
        cur1 = cur1->u;
        cur2 = cur2->u;
      }
      swap(cur1->r, cur2->r);
      if (cur1->r) cur1->r->l = cur1;
      if (cur2->r) cur2->r->l = cur2;
    }
    for (long long i = 0; i < width; i++) {
      if (i) {
        cur1 = cur1->l;
        cur2 = cur2->l;
      }
      swap(cur1->u, cur2->u);
      if (cur1->u) cur1->u->d = cur1;
      if (cur2->u) cur2->u->d = cur2;
    }
  }
  Cell *begcell1 = cells[0][0];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++)
      if (!cells[i][j]->l && !cells[i][j]->u) {
        begcell1 = cells[i][j];
      }
  for (long long i = 0; i < n; i++) {
    Cell *curcell = begcell1;
    assert(curcell->r);
    for (long long j = 0; j < m; j++) {
      answer[i][j] = curcell->val;
      if (j < m - 1) assert(curcell->r);
      curcell = curcell->r;
    }
    begcell1 = begcell1->d;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) cout << answer[i][j] << " ";
    cout << endl;
  }
}
