#include <bits/stdc++.h>
constexpr int N = 1100;
struct Point {
  int x, y;
};
struct Node {
  Point u, d, l, r;
} board[N][N];
int a, b, c, d, h, w;
int under[N][N];
int n, m;
void output() {
  for (int i = 1; i <= n; ++i) {
    int x = i, y = 0;
    for (int i = 0; i < m; ++i) {
      int nx = board[x][y].r.x;
      int ny = board[x][y].r.y;
      x = nx;
      y = ny;
      std::cout << under[x][y] << " \n"[i == m - 1];
    }
  }
}
void work() {
  int altx = a;
  int alty = 0;
  for (int i = 0; i < b; ++i) {
    int nx = board[altx][alty].r.x;
    int ny = board[altx][alty].r.y;
    altx = nx;
    alty = ny;
  }
  int bltx = c;
  int blty = 0;
  for (int i = 0; i < d; ++i) {
    int nx = board[bltx][blty].r.x;
    int ny = board[bltx][blty].r.y;
    bltx = nx;
    blty = ny;
  }
  for (int i = 0; i < h; ++i) {
    int alx = board[altx][alty].l.x;
    int aly = board[altx][alty].l.y;
    int blx = board[bltx][blty].l.x;
    int bly = board[bltx][blty].l.y;
    board[alx][aly].r.x = bltx;
    board[alx][aly].r.y = blty;
    board[blx][bly].r.x = altx;
    board[blx][bly].r.y = alty;
    board[altx][alty].l.x = blx;
    board[altx][alty].l.y = bly;
    board[bltx][blty].l.x = alx;
    board[bltx][blty].l.y = aly;
    if (i == h - 1) break;
    int adx = board[altx][alty].d.x;
    int ady = board[altx][alty].d.y;
    int bdx = board[bltx][blty].d.x;
    int bdy = board[bltx][blty].d.y;
    altx = adx;
    alty = ady;
    bltx = bdx;
    blty = bdy;
  }
  for (int i = 0; i < w; ++i) {
    int adx = board[altx][alty].d.x;
    int ady = board[altx][alty].d.y;
    int bdx = board[bltx][blty].d.x;
    int bdy = board[bltx][blty].d.y;
    board[adx][ady].u.x = bltx;
    board[adx][ady].u.y = blty;
    board[bdx][bdy].u.x = altx;
    board[bdx][bdy].u.y = alty;
    board[altx][alty].d.x = bdx;
    board[altx][alty].d.y = bdy;
    board[bltx][blty].d.x = adx;
    board[bltx][blty].d.y = ady;
    if (i == w - 1) break;
    int arx = board[altx][alty].r.x;
    int ary = board[altx][alty].r.y;
    int brx = board[bltx][blty].r.x;
    int bry = board[bltx][blty].r.y;
    altx = arx;
    alty = ary;
    bltx = brx;
    blty = bry;
  }
  for (int i = 0; i < h; ++i) {
    int arx = board[altx][alty].r.x;
    int ary = board[altx][alty].r.y;
    int brx = board[bltx][blty].r.x;
    int bry = board[bltx][blty].r.y;
    board[arx][ary].l.x = bltx;
    board[arx][ary].l.y = blty;
    board[brx][bry].l.x = altx;
    board[brx][bry].l.y = alty;
    board[altx][alty].r.x = brx;
    board[altx][alty].r.y = bry;
    board[bltx][blty].r.x = arx;
    board[bltx][blty].r.y = ary;
    if (i == h - 1) break;
    int aux = board[altx][alty].u.x;
    int auy = board[altx][alty].u.y;
    int bux = board[bltx][blty].u.x;
    int buy = board[bltx][blty].u.y;
    altx = aux;
    alty = auy;
    bltx = bux;
    blty = buy;
  }
  for (int i = 0; i < w; ++i) {
    int aux = board[altx][alty].u.x;
    int auy = board[altx][alty].u.y;
    int bux = board[bltx][blty].u.x;
    int buy = board[bltx][blty].u.y;
    board[aux][auy].d.x = bltx;
    board[aux][auy].d.y = blty;
    board[bux][buy].d.x = altx;
    board[bux][buy].d.y = alty;
    board[altx][alty].u.x = bux;
    board[altx][alty].u.y = buy;
    board[bltx][blty].u.x = aux;
    board[bltx][blty].u.y = auy;
    if (i == w - 1) break;
    int alx = board[altx][alty].l.x;
    int aly = board[altx][alty].l.y;
    int blx = board[bltx][blty].l.x;
    int bly = board[bltx][blty].l.y;
    altx = alx;
    alty = aly;
    bltx = blx;
    blty = bly;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int q;
  std::cin >> n >> m >> q;
  for (int i = 0; i <= n + 1; ++i) {
    for (int j = 0; j <= m + 1; ++j) {
      board[i][j].u.x = i - 1;
      board[i][j].u.y = j;
      board[i][j].d.x = i + 1;
      board[i][j].d.y = j;
      board[i][j].l.x = i;
      board[i][j].l.y = j - 1;
      board[i][j].r.x = i;
      board[i][j].r.y = j + 1;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      std::cin >> under[i][j];
    }
  }
  for (int i = 0; i < q; ++i) {
    std::cin >> a >> b >> c >> d >> h >> w;
    work();
  }
  output();
  return 0;
}
