Problem: Vasiliy finally got to work, where there is a huge amount of tasks waiting for him. Vasiliy is given a matrix consisting of n rows and m columns and q tasks. Each task is to swap two submatrices of the given matrix.

For each task Vasiliy knows six integers ai, bi, ci, di, hi, wi, where ai is the index of the row where the top-left corner of the first rectangle is located, bi is the index of its column, ci is the index of the row of the top-left corner of the second rectangle, di is the index of its column, hi is the height of the rectangle and wi is its width.

It's guaranteed that two rectangles in one query do not overlap and do not touch, that is, no cell belongs to both rectangles, and no two cells belonging to different rectangles share a side. However, rectangles are allowed to share an angle.

Vasiliy wants to know how the matrix will look like after all tasks are performed.

Input

The first line of the input contains three integers n, m and q (2 ≤ n, m ≤ 1000, 1 ≤ q ≤ 10 000) — the number of rows and columns in matrix, and the number of tasks Vasiliy has to perform.

Then follow n lines containing m integers vi, j (1 ≤ vi, j ≤ 109) each — initial values of the cells of the matrix.

Each of the following q lines contains six integers ai, bi, ci, di, hi, wi (1 ≤ ai, ci, hi ≤ n, 1 ≤ bi, di, wi ≤ m).

Output

Print n lines containing m integers each — the resulting matrix.

Examples

Input

4 4 2
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
1 1 3 3 2 2
3 1 1 3 2 2


Output

4 4 3 3
4 4 3 3
2 2 1 1
2 2 1 1


Input

4 2 1
1 1
1 1
2 2
2 2
1 1 4 1 1 2


Output

2 2
1 1
2 2
1 1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
mt19937 ggen;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
struct bead {
  int val;
  bead *nxt[4];
};
int n, m, q;
bead a[1010][1010];
struct angles {
  bead *a[4];
};
pair<bead *, angles> disconn(bead *cur, int h, int w) {
  angles pp;
  int dim[2] = {w, h};
  for (int pos = 0; pos < 4; pos++) {
    int d0 = pos;
    int d1 = pos + 1;
    int d2 = pos + 2;
    if (d1 >= 4) d1 -= 4;
    if (d2 >= 4) d2 -= 4;
    for (int i = 0; i < dim[pos & 1]; i++) {
      bead *nb = cur->nxt[d0];
      if (i == 0) pp.a[pos] = nb;
      nb->nxt[d2] = NULL;
      cur->nxt[d0] = NULL;
      if (i != dim[pos & 1] - 1) cur = cur->nxt[d1];
    }
  }
  return pair<bead *, angles>(cur, pp);
}
void conn(bead *cur, angles pp, int h, int w) {
  int dim[2] = {w, h};
  bead *nb;
  for (int pos = 0; pos < 4; pos++) {
    int d0 = pos;
    int d1 = pos + 1;
    int d2 = pos + 2;
    if (d1 >= 4) d1 -= 4;
    if (d2 >= 4) d2 -= 4;
    nb = pp.a[pos];
    for (int i = 0; i < dim[pos & 1]; i++) {
      nb->nxt[d2] = cur;
      cur->nxt[d0] = nb;
      if (i != dim[pos & 1] - 1) cur = cur->nxt[d1];
      nb = nb->nxt[d1];
    }
  }
}
void solve() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) {
      int x;
      if (i == 0 || i == n + 1 || j == 0 || j == m + 1)
        x = 0;
      else
        scanf("%d", &x);
      a[i][j].val = x;
      for (int k = 0; k < 4; k++) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        a[i][j].nxt[k] = &a[ni][nj];
      }
    }
  }
  for (int ts = 0; ts < q; ts++) {
    int ax, ay, bx, by, h, w;
    scanf("%d%d%d%d%d%d", &ax, &ay, &bx, &by, &h, &w);
    bead *cura, *curb;
    cura = curb = &a[0][0];
    for (int i = 0; i < ax; i++) cura = cura->nxt[2];
    for (int i = 0; i < ay; i++) cura = cura->nxt[1];
    for (int i = 0; i < bx; i++) curb = curb->nxt[2];
    for (int i = 0; i < by; i++) curb = curb->nxt[1];
    auto ta = disconn(cura, h, w);
    auto tb = disconn(curb, h, w);
    conn(tb.first, ta.second, h, w);
    conn(ta.first, tb.second, h, w);
  }
  for (int i = 1; i <= n; i++) {
    bead *cur = &a[i][0];
    for (int j = 0; j < m; j++) {
      cur = cur->nxt[1];
      printf("%d ", cur->val);
    }
    printf("\n");
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(1313);
  ggen = mt19937(13);
  solve();
  return 0;
}