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>
const char en = '\n';
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U>& par) {
  out << par.first << " " << par.second << en;
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  for (long long i = 0; i < (long long)(v.size()); i++) {
    if (i) out << " ";
    cout << v[i];
  }
  return out;
}
struct item {
  item* p;
  item* d;
  long long h;
  item(item* pp, item* dd, long long hod = -1) {
    p = pp;
    d = dd;
    h = hod;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<item>> V(n + 10, vector<item>(m + 10, item(NULL, NULL)));
  for (long long i = 0; i < (long long)(n + 3); i++)
    for (long long j = 0; j < (long long)(m + 3); j++)
      V[i][j] = item(&V[i][j + 1], &V[i + 1][j]);
  for (long long i = 0; i < (long long)(n); i++)
    for (long long j = 0; j < (long long)(m); j++) {
      int x;
      cin >> x;
      V[i + 1][j + 1].h = x;
    }
  while (q--) {
    int a, b, c, d, h, w;
    cin >> a >> b >> c >> d >> h >> w;
    item s1 = V[0][0];
    item s2 = V[0][0];
    item* roh1 = &V[0][0];
    for (long long i = 0; i < (long long)(a - 1); i++) roh1 = roh1->d;
    for (long long i = 0; i < (long long)(b - 1); i++) roh1 = roh1->p;
    item* roh2 = &V[0][0];
    for (long long i = 0; i < (long long)(c - 1); i++) roh2 = roh2->d;
    for (long long i = 0; i < (long long)(d - 1); i++) roh2 = roh2->p;
    item* prvy1 = roh1->d->p;
    item* prvy2 = roh2->d->p;
    item* roh11 = roh1->p;
    item* roh21 = roh2->p;
    for (long long i = 0; i < (long long)(w); i++) {
      swap(roh11->d, roh21->d);
      roh11 = roh11->p;
      roh21 = roh21->p;
    }
    roh11 = roh1->d;
    roh21 = roh2->d;
    for (long long i = 0; i < (long long)(h); i++) {
      swap(roh11->p, roh21->p);
      roh11 = roh11->d;
      roh21 = roh21->d;
    }
    roh11 = prvy1;
    roh21 = prvy2;
    for (long long i = 0; i < (long long)(w - 1); i++) {
      roh11 = roh11->p;
      roh21 = roh21->p;
    }
    for (long long i = 0; i < (long long)(h); i++) {
      swap(roh11->p, roh21->p);
      roh11 = roh11->d;
      roh21 = roh21->d;
    }
    roh11 = prvy1;
    roh21 = prvy2;
    for (long long i = 0; i < (long long)(h - 1); i++) {
      roh11 = roh11->d;
      roh21 = roh21->d;
    }
    for (long long i = 0; i < (long long)(w); i++) {
      swap(roh11->d, roh21->d);
      roh11 = roh11->p;
      roh21 = roh21->p;
    }
  }
  item* xroh = (&V[0][0])->p->d;
  for (long long i = 0; i < (long long)(n); i++) {
    item* xroh1 = xroh;
    for (long long j = 0; j < (long long)(m); j++) {
      cout << xroh1->h << " \n"[j == m - 1];
      xroh1 = xroh1->p;
    }
    xroh = xroh->d;
  }
}