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 val;
  node *u, *d, *l, *r;
};
vector<vector<node>> aa;
node* f(int x, int y) {
  node* temp = &aa[0][0];
  for (int i = 1; i <= x; i += 1) {
    temp = temp->d;
  }
  for (int i = 1; i <= y; i += 1) {
    temp = temp->r;
  }
  return temp;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  aa = vector<vector<node>>(n + 2, vector<node>(m + 2));
  for (int i = 0; i <= n + 1; i += 1) {
    for (int j = 0; j <= m + 1; j += 1) {
      if (i) {
        aa[i][j].u = &aa[i - 1][j];
        aa[i - 1][j].d = &aa[i][j];
      }
      if (j) {
        aa[i][j].l = &aa[i][j - 1];
        aa[i][j - 1].r = &aa[i][j];
      }
    }
  }
  for (int i = 1; i <= n; i += 1) {
    for (int j = 1; j <= m; j += 1) {
      cin >> aa[i][j].val;
    }
  }
  int a, b, c, d, h, w;
  node *c1, *c2, *c3, *c4, *t1, *t2, *t3, *t4;
  for (int qq = 1; qq <= q; qq += 1) {
    cin >> a >> b >> c >> d >> h >> w;
    c1 = f(a, b), c2 = f(a, b + w - 1), c3 = f(c, d), c4 = f(c, d + w - 1);
    for (int i = 1; i <= h; i += 1) {
      t1 = c1->l, t2 = c2->r, t3 = c3->l, t4 = c4->r;
      t1->r = c3, c3->l = t1, t2->l = c4, c4->r = t2;
      t3->r = c1, c1->l = t3, t4->l = c2, c2->r = t4;
      c1 = c1->d, c2 = c2->d, c3 = c3->d, c4 = c4->d;
    }
    c1 = f(a, b), c2 = f(a + h - 1, b), c3 = f(c, d), c4 = f(c + h - 1, d);
    for (int i = 1; i <= w; i += 1) {
      t1 = c1->u, t2 = c2->d, t3 = c3->u, t4 = c4->d;
      t1->d = c3, c3->u = t1, t2->u = c4, c4->d = t2;
      t3->d = c1, c1->u = t3, t4->u = c2, c2->d = t4;
      c1 = c1->r, c2 = c2->r, c3 = c3->r, c4 = c4->r;
    }
  }
  node* temp = &aa[0][0];
  temp = temp->d->r;
  node* temp2 = temp;
  for (int i = 1; i <= n; i += 1) {
    for (int j = 1; j <= m; j += 1) {
      cout << temp2->val << " ";
      temp2 = temp2->r;
    }
    temp2 = temp = temp->d;
    cout << "\n";
  }
}