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;
void readi(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readll(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
void writes(string s) { puts(s.c_str()); }
void writeln() { writes(""); }
void writei(int x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
void writell(long long x) {
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline long long inc(int &x) { return ++x; }
inline long long inc(long long &x) { return ++x; }
inline long long inc(int &x, long long y) { return x += y; }
inline long long inc(long long &x, long long y) { return x += y; }
inline double inc(double &x, double y) { return x += y; }
inline long long dec(int &x) { return --x; }
inline long long dec(long long &x) { return --x; }
inline long long dec(int &x, long long y) { return x -= y; }
inline long long dec(long long &x, long long y) { return x -= y; }
inline double dec(double &x, double y) { return x -= y; }
inline long long mul(int &x) { return x = ((long long)x) * x; }
inline long long mul(long long &x) { return x = x * x; }
inline long long mul(int &x, long long y) { return x *= y; }
inline long long mul(long long &x, long long y) { return x *= y; }
inline double mul(double &x, double y) { return x *= y; }
inline long long divi(int &x) { return x = sqrt(x); }
inline long long divi(long long &x) { return x = sqrt(x); }
inline long long divi(int &x, long long y) { return x /= y; }
inline long long divi(long long &x, long long y) { return x /= y; }
inline double divi(double &x, double y) { return x /= y; }
inline long long mod(int &x, long long y) { return x %= y; }
inline long long mod(long long &x, long long y) { return x %= y; }
int n, m, q, i, j, x, y, xx, yy, lx, ly, cnt, tmp[1111][1111];
struct nd {
  int r, d, x, y, key;
} a[1111 * 1111];
inline int getxy(int x, int y) { return x * (m + 1) + y; }
int find(int x, int y) {
  int t = 0, i;
  if ((1) <= ((x)))
    for (((i)) = (1); ((i)) <= ((x)); ((i))++) t = a[t].d;
  if ((1) <= ((y)))
    for (((i)) = (1); ((i)) <= ((y)); ((i))++) t = a[t].r;
  return t;
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin >> n >> m >> q;
  if ((0) <= (n))
    for ((i) = (0); (i) <= (n); (i)++)
      if ((0) <= (m))
        for ((j) = (0); (j) <= (m); (j)++) {
          if (i && j) cin >> tmp[i][j];
          a[getxy(i, j)].x = i;
          a[getxy(i, j)].y = j;
          a[getxy(i, j)].key = tmp[i][j];
          a[getxy(i, j)].d = getxy(i + 1, j);
          a[getxy(i, j)].r = getxy(i, j + 1);
        }
  if ((1) <= ((q)))
    for (((j)) = (1); ((j)) <= ((q)); ((j))++) {
      cin >> x >> y >> xx >> yy >> lx >> ly;
      int t1 = find(x - 1, y - 1), t2 = find(xx - 1, yy - 1);
      int t3 = t1, t4 = t2;
      if ((1) <= ((lx)))
        for (((i)) = (1); ((i)) <= ((lx)); ((i))++) {
          t3 = a[t3].d;
          t4 = a[t4].d;
          swap(a[t3].r, a[t4].r);
        }
      if ((1) <= ((ly)))
        for (((i)) = (1); ((i)) <= ((ly)); ((i))++) {
          t3 = a[t3].r;
          t4 = a[t4].r;
          swap(a[t3].d, a[t4].d);
        }
      t3 = t1;
      t4 = t2;
      if ((1) <= ((ly)))
        for (((i)) = (1); ((i)) <= ((ly)); ((i))++) {
          t3 = a[t3].r;
          t4 = a[t4].r;
          swap(a[t3].d, a[t4].d);
        }
      if ((1) <= ((lx)))
        for (((i)) = (1); ((i)) <= ((lx)); ((i))++) {
          t3 = a[t3].d;
          t4 = a[t4].d;
          swap(a[t3].r, a[t4].r);
        }
    }
  int pos = find(1, 1);
  if ((1) <= ((n)))
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
      int t = pos;
      if ((1) <= ((m)))
        for (((j)) = (1); ((j)) <= ((m)); ((j))++) {
          cout << a[t].key << ' ';
          t = a[t].r;
        }
      cout << endl;
      pos = a[pos].d;
    }
  return 0;
}