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 std::swap;
struct o {
  int r, d, val;
} l[1001 * 1001];
inline int get(int x, int y) {
  int nw = 1, i;
  for (i = 0; i < y; i++) ++nw;
  for (i = 0; i < x; i++) nw = l[nw].d;
  return nw;
}
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return x;
}
int main() {
  int n = read(), m = read(), q = read(), p = 1, i, k;
  for (i = 1; i <= (n + 1) * (m + 1); i++) {
    if (i > m + 1 && (i - 1) % (m + 1) != 0) l[i].val = read();
    if (i % (m + 1) != 0) l[i].r = i + 1;
    if (i <= n * (m + 1)) l[i].d = i + m + 1;
  }
  for (k = 0; k < q; k++) {
    int x1 = read(), y1 = read(), x2 = read(), y2 = read(), h = read(),
        w = read(), h1 = get(x1 - 1, y1 - 1), h2 = get(x2 - 1, y2 - 1),
        w1 = l[h1].r, w2 = l[h2].r;
    h1 = l[h1].d, h2 = l[h2].d;
    int h3 = get(x1, y1 + (w - 1)), h4 = get(x2, y2 + (w - 1)),
        w3 = get(x1 + (h - 1), y1), w4 = get(x2 + (h - 1), y2);
    for (i = 0; i < h; i++)
      swap(l[h1].r, l[h2].r), h1 = l[h1].d, h2 = l[h2].d,
                              swap(l[h3].r, l[h4].r), h3 = l[h3].d,
                              h4 = l[h4].d;
    for (i = 0; i < w; i++)
      swap(l[w1].d, l[w2].d), w1 = l[w1].r, w2 = l[w2].r,
                              swap(l[w3].d, l[w4].d), w3 = l[w3].r,
                              w4 = l[w4].r;
  }
  for (i = 0; i < n; i++) {
    p = l[p].d;
    for (int j = 0, nw = l[p].r; j < m; ++j) {
      printf("%d ", l[nw].val);
      nw = l[nw].r;
    }
    putchar('\n');
  }
}