#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int ts, kk = 1;
int dx[] = {1, 0};
int dy[] = {0, 1};
int a[1005][1005];
pair<int, int> nx[2][1005][1005];
int n, m;
int u, v, x, y, h, w;
pair<int, int> q1, q2, q3, q4;
int main() {
  int t, i, j, k;
  scanf("%d%d%d", &n, &m, &ts);
  for (i = 1; i < n + 1; i++) {
    for (j = 1; j < m + 1; j++) {
      scanf("%d", &a[i][j]);
      for (k = 0; k < 2; k++)
        nx[k][i][j] = pair<int, int>(i + dx[k], j + dy[k]);
    }
  }
  for (j = 0; j < m + 1; j++)
    for (k = 0; k < 2; k++) nx[k][0][j] = pair<int, int>(dx[k], j + dy[k]);
  for (j = 0; j < n + 1; j++)
    for (k = 0; k < 2; k++) nx[k][j][0] = pair<int, int>(j + dx[k], dy[k]);
  while (ts--) {
    scanf("%d%d%d%d%d%d", &u, &v, &x, &y, &h, &w);
    q1 = pair<int, int>(u - 1, 0);
    q2 = pair<int, int>(x - 1, 0);
    v--, y--;
    t = min(v, y);
    for (j = 0; j < t; j++)
      q1 = nx[1][q1.first][q1.second], q2 = nx[1][q2.first][q2.second];
    for (k = j; k < v; k++) q1 = nx[1][q1.first][q1.second];
    for (k = j; k < y; k++) q2 = nx[1][q2.first][q2.second];
    q3 = q1;
    q4 = q2;
    for (i = 0; i < w; i++) {
      q1 = nx[1][q1.first][q1.second];
      q2 = nx[1][q2.first][q2.second];
      swap(nx[0][q1.first][q1.second], nx[0][q2.first][q2.second]);
    }
    for (i = 0; i < h; i++) {
      q1 = nx[0][q1.first][q1.second];
      q2 = nx[0][q2.first][q2.second];
      swap(nx[1][q1.first][q1.second], nx[1][q2.first][q2.second]);
    }
    q1 = q3;
    q2 = q4;
    for (i = 0; i < h; i++) {
      q1 = nx[0][q1.first][q1.second];
      q2 = nx[0][q2.first][q2.second];
      swap(nx[1][q1.first][q1.second], nx[1][q2.first][q2.second]);
    }
    for (i = 0; i < w; i++) {
      q1 = nx[1][q1.first][q1.second];
      q2 = nx[1][q2.first][q2.second];
      swap(nx[0][q1.first][q1.second], nx[0][q2.first][q2.second]);
    }
  }
  for (i = 1; i <= n; i++) {
    q1 = nx[1][i][0];
    printf("%d", a[q1.first][q1.second]);
    for (q1 = nx[1][q1.first][q1.second]; q1.second <= m;
         q1 = nx[1][q1.first][q1.second]) {
      printf(" %d", a[q1.first][q1.second]);
    }
    puts("");
  }
  return 0;
}
