#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int n, m, q, A[N][N];
pair<int, int> adj[N * N];
int a, b, c, d, h, w;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> q;
  for (int i = (0); i <= (n); ++i) {
    for (int j = (0); j <= (m); ++j) {
      if (i && j) cin >> A[i][j];
      adj[((i) * (m + 1) + (j))].first = ((i + 1) * (m + 1) + (j));
      adj[((i) * (m + 1) + (j))].second = ((i) * (m + 1) + (j + 1));
    }
  }
  for (int i = (1); i <= (q); ++i) {
    cin >> a >> b >> c >> d >> h >> w;
    int pos1 = 0, pos2 = 0;
    for (int j = (1); j <= (a - 1); ++j) pos1 = adj[pos1].first;
    for (int j = (1); j <= (b - 1); ++j) pos1 = adj[pos1].second;
    for (int j = (1); j <= (c - 1); ++j) pos2 = adj[pos2].first;
    for (int j = (1); j <= (d - 1); ++j) pos2 = adj[pos2].second;
    int tpos1 = pos1, tpos2 = pos2;
    for (int j = (1); j <= (h); ++j) {
      tpos1 = adj[tpos1].first;
      tpos2 = adj[tpos2].first;
      swap(adj[tpos1].second, adj[tpos2].second);
    }
    for (int j = (1); j <= (w); ++j) {
      tpos1 = adj[tpos1].second;
      tpos2 = adj[tpos2].second;
      swap(adj[tpos1].first, adj[tpos2].first);
    }
    for (int j = (1); j <= (w); ++j) {
      pos1 = adj[pos1].second;
      pos2 = adj[pos2].second;
      swap(adj[pos1].first, adj[pos2].first);
    }
    for (int j = (1); j <= (h); ++j) {
      pos1 = adj[pos1].first;
      pos2 = adj[pos2].first;
      swap(adj[pos1].second, adj[pos2].second);
    }
  }
  int posi = 0;
  for (int i = (1); i <= (n); ++i) {
    posi = adj[posi].first;
    int pointr = posi;
    for (int j = (1); j <= (m); ++j) {
      pointr = adj[pointr].second;
      cout << A[pointr / (1 + m)][pointr % (m + 1)] << ' ';
    }
    cout << '\n';
  }
}
