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>
using namespace std;
inline int Mul(int x, int y) { return 1ll * x * y % 1000000007; }
inline int Add(int x, int y) {
  return ((x + y) % 1000000007 + 1000000007) % 1000000007;
}
int n, m, Q, tot;
int v[1010 * 1010], id[1010][1010];
int up[1010 * 1010], down[1010 * 1010], l[1010 * 1010], r[1010 * 1010];
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) {
      id[i][j] = ++tot;
      if (i && i <= n && j && j <= m) scanf("%d", &v[tot]);
    }
  }
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) {
      if (i) up[id[i][j]] = id[i - 1][j];
      if (i <= n) down[id[i][j]] = id[i + 1][j];
      if (j) l[id[i][j]] = id[i][j - 1];
      if (j <= m) r[id[i][j]] = id[i][j + 1];
    }
  }
  int x1, y1, x2, y2, h, w, x, y;
  while (Q--) {
    scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &h, &w);
    x = id[x1][0];
    for (int i = 1; i <= y1; i++) x = r[x];
    y = id[x2][0];
    for (int i = 1; i <= y2; i++) y = r[y];
    for (int j = 1; j <= w; j++) {
      down[up[x]] = y;
      down[up[y]] = x;
      swap(up[x], up[y]);
      x = r[x], y = r[y];
    }
    x = l[x], y = l[y];
    for (int j = 1; j <= h; j++) {
      l[r[x]] = y;
      l[r[y]] = x;
      swap(r[x], r[y]);
      x = down[x], y = down[y];
    }
    x = up[x], y = up[y];
    for (int j = 1; j <= w; j++) {
      up[down[x]] = y;
      up[down[y]] = x;
      swap(down[x], down[y]);
      x = l[x], y = l[y];
    }
    x = r[x], y = r[y];
    for (int j = 1; j <= h; j++) {
      r[l[x]] = y;
      r[l[y]] = x;
      swap(l[x], l[y]);
      x = up[x], y = up[y];
    }
  }
  for (int i = 1; i <= n; i++) {
    x = id[i][0];
    for (int j = 1; j <= m; j++) {
      x = r[x];
      printf("%d%c", v[x], j == m ? '\n' : ' ');
    }
  }
  return 0;
}