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 int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x7fffffffffffffff;
const double eps = 1e-8;
unsigned int seed = 19260817;
__inline__ __attribute__((always_inline)) unsigned int Rand() {
  return seed = seed * 998244353u + 1000000007u;
}
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {
  return a > 0 ? a : -a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b) {
  return a < b ? b : a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b) {
  return a < b ? a : b;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {
  (a > b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) bool _cmp(const double &a,
                                                    const double &b) {
  return abs(a - b) <= eps;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void read(_Tp &x) {
  register char ch(getchar());
  bool f(false);
  while (ch < 48 || ch > 57) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (ch >= 48 && ch <= 57)
    x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  if (f) x = -x;
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
__inline__ __attribute__((always_inline)) int read_str(char *s) {
  register char ch(getchar());
  while (ch < 65 || ch > 122 || (ch > 90 && ch < 97)) ch = getchar();
  register char *tar = s;
  *tar = ch, ch = getchar();
  while ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122))
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
const int N = 1005;
int n, m;
__inline__ __attribute__((always_inline)) int id(const int &x, const int &y) {
  return x * (m + 2) + y + 1;
}
struct node {
  int val;
  int l, r, u, d;
} p[N * N];
int GetId(int x, int y) {
  int cur = id(x, 0);
  for (int i = 1; i <= y; ++i) cur = p[cur].r;
  return cur;
}
void solve(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
  int a = GetId(x1, y1), b = GetId(x1, y2);
  int c = GetId(x3, y3), d = GetId(x3, y4);
  int A = GetId(x1, y1), B = GetId(x2, y1);
  int C = GetId(x3, y3), D = GetId(x4, y3);
  for (int i = x1; i <= x2; ++i) {
    std::swap(p[p[a].l].r, p[p[c].l].r);
    std::swap(p[p[b].r].l, p[p[d].r].l);
    std::swap(p[a].l, p[c].l);
    std::swap(p[b].r, p[d].r);
    a = p[a].d, b = p[b].d;
    c = p[c].d, d = p[d].d;
  }
  for (int i = y1; i <= y2; ++i) {
    std::swap(p[p[A].u].d, p[p[C].u].d);
    std::swap(p[p[B].d].u, p[p[D].d].u);
    std::swap(p[A].u, p[C].u);
    std::swap(p[B].d, p[D].d);
    A = p[A].r, B = p[B].r;
    C = p[C].r, D = p[D].r;
  }
}
void print() {
  for (int i = 1; i <= n; ++i) {
    int cur = id(i, 0);
    for (int j = 1; j <= m; ++j) {
      cur = p[cur].r;
      printf("%d ", p[cur].val);
    }
    printf("\n");
  }
}
int main() {
  int q, x;
  read(n, m, q);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      read(x);
      p[id(i, j)] =
          (node){x, id(i, j - 1), id(i, j + 1), id(i - 1, j), id(i + 1, j)};
    }
  }
  for (int i = 1; i <= m; ++i) {
    p[id(0, i)] = (node){0, id(0, i - 1), id(0, i + 1), 0, id(1, i)};
    p[id(n + 1, i)] =
        (node){0, id(n + 1, i - 1), id(n + 1, i + 1), id(n, i), 0};
  }
  for (int i = 1; i <= n; ++i) {
    p[id(i, 0)] = (node){0, 0, id(i, 1), id(i - 1, 0), id(i + 1, 0)};
    p[id(i, m + 1)] =
        (node){0, id(i, m), 0, id(i - 1, m + 1), id(i + 1, m + 1)};
  }
  p[id(0, 0)] = (node){0, 0, id(0, 1), 0, id(1, 0)};
  p[id(0, m + 1)] = (node){0, id(0, m), 0, 0, id(1, m + 1)};
  p[id(n + 1, 0)] = (node){0, 0, id(n + 1, 1), id(n, 0), 0};
  p[id(n + 1, m + 1)] = (node){0, id(n + 1, m), 0, id(n, m + 1), 0};
  int a, b, c, d, h, w;
  while (q--) {
    read(a, b, c, d, h, w);
    solve(a, b, a + h - 1, b + w - 1, c, d, c + h - 1, d + w - 1);
  }
  print();
  return 0;
}