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;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int ts, kk = 1;
int dx[] = {1, 0};
int dy[] = {0, 1};
int a[1005][1005];
pair<int, int> nx[2][1005][1005];
int n, m;
int u, v, x, y, h, w;
pair<int, int> q1, q2, q3, q4;
int main() {
  int t, i, j, k;
  scanf("%d%d%d", &n, &m, &ts);
  for (i = 1; i < n + 1; i++) {
    for (j = 1; j < m + 1; j++) {
      scanf("%d", &a[i][j]);
      for (k = 0; k < 2; k++)
        nx[k][i][j] = pair<int, int>(i + dx[k], j + dy[k]);
    }
  }
  for (j = 0; j < m + 1; j++)
    for (k = 0; k < 2; k++) nx[k][0][j] = pair<int, int>(dx[k], j + dy[k]);
  for (j = 0; j < n + 1; j++)
    for (k = 0; k < 2; k++) nx[k][j][0] = pair<int, int>(j + dx[k], dy[k]);
  while (ts--) {
    scanf("%d%d%d%d%d%d", &u, &v, &x, &y, &h, &w);
    q1 = pair<int, int>(u - 1, 0);
    q2 = pair<int, int>(x - 1, 0);
    v--, y--;
    t = min(v, y);
    for (j = 0; j < t; j++)
      q1 = nx[1][q1.first][q1.second], q2 = nx[1][q2.first][q2.second];
    for (k = j; k < v; k++) q1 = nx[1][q1.first][q1.second];
    for (k = j; k < y; k++) q2 = nx[1][q2.first][q2.second];
    q3 = q1;
    q4 = q2;
    for (i = 0; i < w; i++) {
      q1 = nx[1][q1.first][q1.second];
      q2 = nx[1][q2.first][q2.second];
      swap(nx[0][q1.first][q1.second], nx[0][q2.first][q2.second]);
    }
    for (i = 0; i < h; i++) {
      q1 = nx[0][q1.first][q1.second];
      q2 = nx[0][q2.first][q2.second];
      swap(nx[1][q1.first][q1.second], nx[1][q2.first][q2.second]);
    }
    q1 = q3;
    q2 = q4;
    for (i = 0; i < h; i++) {
      q1 = nx[0][q1.first][q1.second];
      q2 = nx[0][q2.first][q2.second];
      swap(nx[1][q1.first][q1.second], nx[1][q2.first][q2.second]);
    }
    for (i = 0; i < w; i++) {
      q1 = nx[1][q1.first][q1.second];
      q2 = nx[1][q2.first][q2.second];
      swap(nx[0][q1.first][q1.second], nx[0][q2.first][q2.second]);
    }
  }
  for (i = 1; i <= n; i++) {
    q1 = nx[1][i][0];
    printf("%d", a[q1.first][q1.second]);
    for (q1 = nx[1][q1.first][q1.second]; q1.second <= m;
         q1 = nx[1][q1.first][q1.second]) {
      printf(" %d", a[q1.first][q1.second]);
    }
    puts("");
  }
  return 0;
}