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;
struct Node {
  int left, right, up, down, value;
  Node() { left = right = up = down = value = -1; }
};
vector<Node> node;
int N;
int get(int i, int j) {
  int res = 0;
  for (int(ii) = (0); (ii) < (int)(i); ++(ii)) res = node[res].down;
  for (int(jj) = (0); (jj) < (int)(j); ++(jj)) res = node[res].right;
  return res;
}
int main() {
  int M, Q;
  vector<vector<int> > A;
  {
    cin >> N >> M >> Q;
    node = vector<Node>((N + 2) * (M + 2));
    A = vector<vector<int> >(N + 2, vector<int>(M + 2));
    for (int(i) = (1); (i) < (int)(N + 1); ++(i))
      for (int(j) = (1); (j) < (int)(M + 1); ++(j)) scanf("%d", &A[i][j]);
    for (int(i) = (0); (i) < (int)(N + 2); ++(i))
      for (int(j) = (0); (j) < (int)(M + 2); ++(j)) {
        int k = i * (M + 2) + j;
        node[k].value = A[i][j];
        if (i > 0) {
          int up = (i - 1) * (M + 2) + j;
          node[k].up = up;
          node[up].down = k;
        }
        if (j > 0) {
          int left = i * (M + 2) + (j - 1);
          node[k].left = left;
          node[left].right = k;
        }
      }
  }
  while (Q--) {
    int a, b, c, d, h, w;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &h, &w);
    int fi0 = get(a, b), se0 = get(c, d);
    int fi1 = get(a, b + w - 1), se1 = get(c, d + w - 1);
    int fi2 = get(a + h - 1, b), se2 = get(c + h - 1, d);
    {
      int fi = fi0, se = se0;
      for (int(i) = (0); (i) < (int)(h); ++(i)) {
        swap(node[node[fi].left].right, node[node[se].left].right);
        swap(node[fi].left, node[se].left);
        fi = node[fi].down;
        se = node[se].down;
      }
    }
    {
      int fi = fi1, se = se1;
      for (int(i) = (0); (i) < (int)(h); ++(i)) {
        swap(node[node[fi].right].left, node[node[se].right].left);
        swap(node[fi].right, node[se].right);
        fi = node[fi].down;
        se = node[se].down;
      }
    }
    {
      int fi = fi0, se = se0;
      for (int(i) = (0); (i) < (int)(w); ++(i)) {
        swap(node[node[fi].up].down, node[node[se].up].down);
        swap(node[fi].up, node[se].up);
        fi = node[fi].right;
        se = node[se].right;
      }
    }
    {
      int fi = fi2, se = se2;
      for (int(i) = (0); (i) < (int)(w); ++(i)) {
        swap(node[node[fi].down].up, node[node[se].down].up);
        swap(node[fi].down, node[se].down);
        fi = node[fi].right;
        se = node[se].right;
      }
    }
  }
  {
    int head = get(1, 1);
    for (int(i) = (0); (i) < (int)(N); ++(i)) {
      int cur = head;
      for (int(j) = (0); (j) < (int)(M); ++(j)) {
        printf("%d%c", node[cur].value, j != M - 1 ? ' ' : '\n');
        cur = node[cur].right;
      }
      head = node[head].down;
    }
  }
}