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;
inline long long read() {
  long long x = 0;
  char zf = 1;
  char ch = getchar();
  while (ch != '-' && !isdigit(ch)) ch = getchar();
  if (ch == '-') zf = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * zf;
}
void write(long long y) {
  if (y < 0) putchar('-'), y = -y;
  if (y > 9) write(y / 10);
  putchar(y % 10 + 48);
}
void writeln(const long long y) {
  write(y);
  putchar('\n');
}
int i, j, k, m, n, x, y, z, cnt, p;
struct node {
  int v, D, S;
} a[2000010];
void print(int x, int fla) {
  if (!x) return;
  write(a[x].v);
  putchar(' ');
  if (!a[x].D) putchar('\n');
  print(a[x].D, 0);
  if (fla) print(a[x].S, 1);
}
int main() {
  n = read() + 1;
  m = read() + 1;
  k = read();
  for (register int i = 1; i <= n; i++)
    for (register int j = 1; j <= m; j++) {
      int v = (i - 1) * m + j;
      if (i > 1 && j > 1) a[v].v = read();
      if (i != n) a[v].S = v + m;
      if (j != m) a[v].D = v + 1;
    }
  while (k--) {
    int X1 = read(), Y1 = read(), X2 = read(), Y2 = read(), L = read(),
        C = read();
    int g1 = 1, g2 = 1, g3, g4;
    while (--X1) g1 = a[g1].S;
    while (--X2) g2 = a[g2].S;
    while (--Y1) g1 = a[g1].D;
    while (--Y2) g2 = a[g2].D;
    g3 = g1;
    g4 = g2;
    for (register int i = 1; i <= L; i++) {
      g1 = a[g1].S;
      g2 = a[g2].S;
      swap(a[g1].D, a[g2].D);
    }
    for (register int i = 1; i <= C; i++) {
      g1 = a[g1].D;
      g2 = a[g2].D;
      swap(a[g1].S, a[g2].S);
    }
    for (register int i = 1; i <= C; i++) {
      g3 = a[g3].D;
      g4 = a[g4].D;
      swap(a[g3].S, a[g4].S);
    }
    for (register int i = 1; i <= L; i++) {
      g3 = a[g3].S;
      g4 = a[g4].S;
      swap(a[g3].D, a[g4].D);
    }
  }
  int pla = a[a[1].D].S;
  print(pla, 1);
  return 0;
}