#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
const long long INF = 1e16;
const int K = 32;
int mx[N][N];
int ans[N][N];
pair<int, int> r[N][N];
pair<int, int> down[N][N];
int n, m, q;
pair<int, int> real(pair<int, int> q) {
  pair<int, int> t = make_pair(0, 0);
  for (int i = 0; i < q.first; i++) {
    t = down[t.first][t.second];
  }
  for (int j = 0; j < q.second; j++) {
    t = r[t.first][t.second];
  }
  return t;
}
int main() {
  scanf(" %d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf(" %d", &mx[i][j]);
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      r[i][j] = make_pair(i, j + 1);
      down[i][j] = make_pair(i + 1, j);
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    int c, d;
    int h, w;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &h, &w);
    pair<int, int> q1 = real(make_pair(a - 1, b));
    pair<int, int> q2 = real(make_pair(c - 1, d));
    pair<int, int> q3 = real(make_pair(a + h - 1, b));
    pair<int, int> q4 = real(make_pair(c + h - 1, d));
    for (int j = 0; j < w; j++) {
      swap(down[q1.first][q1.second], down[q2.first][q2.second]);
      swap(down[q3.first][q3.second], down[q4.first][q4.second]);
      q1 = r[q1.first][q1.second];
      q2 = r[q2.first][q2.second];
      q3 = r[q3.first][q3.second];
      q4 = r[q4.first][q4.second];
    }
    pair<int, int> p1 = real(make_pair(a, b - 1));
    pair<int, int> p2 = real(make_pair(c, d - 1));
    pair<int, int> p3 = real(make_pair(a, b + w - 1));
    pair<int, int> p4 = real(make_pair(c, d + w - 1));
    for (int j = 0; j < h; j++) {
      swap(r[p1.first][p1.second], r[p2.first][p2.second]);
      swap(r[p3.first][p3.second], r[p4.first][p4.second]);
      p1 = down[p1.first][p1.second];
      p2 = down[p2.first][p2.second];
      p3 = down[p3.first][p3.second];
      p4 = down[p4.first][p4.second];
    }
  }
  pair<int, int> t = make_pair(0, 0);
  for (int i = 0; i <= n; i++) {
    pair<int, int> nt = t;
    for (int j = 0; j <= m; j++) {
      ans[i][j] = mx[nt.first][nt.second];
      nt = r[nt.first][nt.second];
    }
    t = down[t.first][t.second];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", ans[i][j]);
    }
    printf("\n");
  }
  return 0;
}
