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 LL2D {
  LL2D* above = nullptr;
  LL2D* left = nullptr;
  LL2D* under = nullptr;
  LL2D* right = nullptr;
  int val;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<LL2D*>> v(n + 2, vector<LL2D*>(m + 2, nullptr));
  for (int i = 0; i < n + 2; i++) {
    for (int j = 0; j < m + 2; j++) {
      v[i][j] = new LL2D;
    }
  }
  LL2D* root = v[0][0];
  for (int i = 0; i < n + 2; i++) {
    for (int j = 0; j < m + 2; j++) {
      if (i) v[i][j]->above = v[i - 1][j];
      if (j) v[i][j]->left = v[i][j - 1];
      if (i < n + 1) v[i][j]->under = v[i + 1][j];
      if (j < m + 1) v[i][j]->right = v[i][j + 1];
      if (i && i < n + 1 && j && j < m + 1) cin >> v[i][j]->val;
    }
  }
  auto print = [root, n, m]() {
    LL2D* current_row = root;
    for (int i = 0; i < n; i++) {
      current_row = current_row->under;
      LL2D* current = current_row->right;
      for (int j = 0; j < m; j++) {
        cout << current->val << ' ';
        current = current->right;
      }
      cout << '\n';
    }
  };
  for (int idx = 0; idx < q; idx++) {
    int a, b, c, d, h, w;
    cin >> a >> b >> c >> d >> h >> w;
    LL2D* cur1 = root;
    for (int i = 0; i < a; i++) cur1 = cur1->under;
    for (int i = 0; i < b; i++) cur1 = cur1->right;
    LL2D* cur2 = root;
    for (int i = 0; i < c; i++) cur2 = cur2->under;
    for (int i = 0; i < d; i++) cur2 = cur2->right;
    for (int i = 0; i < h; i++) {
      LL2D* left1 = cur1->left;
      LL2D* left2 = cur2->left;
      left1->right = cur2;
      left2->right = cur1;
      cur1->left = left2;
      cur2->left = left1;
      if (i + 1 < h) cur1 = cur1->under, cur2 = cur2->under;
    }
    for (int i = 0; i < w; i++) {
      LL2D* under1 = cur1->under;
      LL2D* under2 = cur2->under;
      under1->above = cur2;
      under2->above = cur1;
      cur1->under = under2;
      cur2->under = under1;
      if (i + 1 < w) cur1 = cur1->right, cur2 = cur2->right;
    }
    for (int i = 0; i < h; i++) {
      LL2D* right1 = cur1->right;
      LL2D* right2 = cur2->right;
      right1->left = cur2;
      right2->left = cur1;
      cur1->right = right2;
      cur2->right = right1;
      if (i + 1 < h) cur1 = cur1->above, cur2 = cur2->above;
    }
    for (int i = 0; i < w; i++) {
      LL2D* above1 = cur1->above;
      LL2D* above2 = cur2->above;
      above1->under = cur2;
      above2->under = cur1;
      cur1->above = above2;
      cur2->above = above1;
      if (i + 1 < w) cur1 = cur1->left, cur2 = cur2->left;
    }
  }
  print();
}