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;
int const GRAY = -2;
int const BLACK = -1;
int const WHITE = 0;
int const INF = 1e8;
long long const INFe15 = 1e15;
long long const INFe64 = 1e18;
inline double sqr(double a) { return a * a; }
template <typename T>
void alert(const T& t) {
  cout << t;
  exit(0);
}
struct cell_t {
  int l, r, u, d;
  int v;
};
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<cell_t> v((n + 2) * (m + 2));
  for (int i = 0; i < n + 2; i++) {
    for (int j = 0; j < m + 2; j++) {
      if (i && j && i <= n && j <= m) {
        scanf("%d", &v[i * m + j].v);
      }
      v[i * m + j].u = (i - 1) * m + j;
      v[i * m + j].d = (i + 1) * m + j;
      v[i * m + j].l = i * m + (j - 1);
      v[i * m + j].r = i * m + (j + 1);
    }
  }
  for (int z = 0; z < q; z++) {
    int a, b, c, d, h, w;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &h, &w);
    int one = 0;
    for (int i = 0; i < a; i++) one = v[one].d;
    for (int j = 0; j < b; j++) one = v[one].r;
    int two = 0;
    for (int i = 0; i < c; i++) two = v[two].d;
    for (int j = 0; j < d; j++) two = v[two].r;
    swap(v[v[one].u].d, v[v[two].u].d);
    swap(v[one].u, v[two].u);
    for (int i = 1; i < w; i++) {
      one = v[one].r;
      two = v[two].r;
      swap(v[v[one].u].d, v[v[two].u].d);
      swap(v[one].u, v[two].u);
    }
    swap(v[v[one].r].l, v[v[two].r].l);
    swap(v[one].r, v[two].r);
    for (int i = 1; i < h; i++) {
      one = v[one].d;
      two = v[two].d;
      swap(v[v[one].r].l, v[v[two].r].l);
      swap(v[one].r, v[two].r);
    }
    swap(v[v[one].d].u, v[v[two].d].u);
    swap(v[one].d, v[two].d);
    for (int i = 1; i < w; i++) {
      one = v[one].l;
      two = v[two].l;
      swap(v[v[one].d].u, v[v[two].d].u);
      swap(v[one].d, v[two].d);
    }
    swap(v[v[one].l].r, v[v[two].l].r);
    swap(v[one].l, v[two].l);
    for (int i = 1; i < h; i++) {
      one = v[one].u;
      two = v[two].u;
      swap(v[v[one].l].r, v[v[two].l].r);
      swap(v[one].l, v[two].l);
    }
  }
  int line = 0;
  for (int i = 0; i < n; i++) {
    line = v[line].d;
    int col = line;
    for (int j = 0; j < m; j++) {
      col = v[col].r;
      printf("%d ", v[col].v);
    }
    cout << endl;
  }
  return 0;
}