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>
typedef struct node {
  int right;
  int down;
} node;
char* pdata;
node nodes[1048576];
int pnum[1048576];
char data[16777216];
int locate_node2(int row, const int col);
inline int locate_node2(int row, const int col) {
  register int inode = col;
  while (row--) {
    inode = nodes[inode].down;
  }
  return inode;
}
void main2(int q);
inline void main2(int q) {
  int a, b, c, d, h, w, nu1, nu2;
  do {
    while ((a = *(pdata++) - '0') < 0)
      ;
    while ((nu2 = *(pdata++) - '0') >= 0) a = (a << 3) + (a << 1) + nu2;
    ;
    while ((b = *(pdata++) - '0') < 0)
      ;
    while ((nu2 = *(pdata++) - '0') >= 0) b = (b << 3) + (b << 1) + nu2;
    ;
    while ((c = *(pdata++) - '0') < 0)
      ;
    while ((nu2 = *(pdata++) - '0') >= 0) c = (c << 3) + (c << 1) + nu2;
    ;
    while ((d = *(pdata++) - '0') < 0)
      ;
    while ((nu2 = *(pdata++) - '0') >= 0) d = (d << 3) + (d << 1) + nu2;
    ;
    while ((h = *(pdata++) - '0') < 0)
      ;
    while ((nu2 = *(pdata++) - '0') >= 0) h = (h << 3) + (h << 1) + nu2;
    ;
    while ((w = *(pdata++) - '0') < 0)
      ;
    while ((nu2 = *(pdata++) - '0') >= 0) w = (w << 3) + (w << 1) + nu2;
    ;
    int lt1a, lt1b, lt2a, lt2b;
    lt1a = lt1b = locate_node2(a - 1, b - 1);
    lt2a = lt2b = locate_node2(c - 1, d - 1);
    nu1 = w;
    do {
      lt1a = nodes[lt1a].right;
      lt2a = nodes[lt2a].right;
      register int t1 = nodes[lt1a].down;
      register int t2 = nodes[lt2a].down;
      nodes[lt2a].down = t1;
      nodes[lt1a].down = t2;
    } while (--nu1);
    ;
    nu1 = h;
    do {
      lt1b = nodes[lt1b].down;
      lt2b = nodes[lt2b].down;
      register int t1 = nodes[lt1b].right;
      register int t2 = nodes[lt2b].right;
      nodes[lt2b].right = t1;
      nodes[lt1b].right = t2;
      lt1a = nodes[lt1a].down;
      lt2a = nodes[lt2a].down;
      t1 = nodes[lt1a].right;
      t2 = nodes[lt2a].right;
      nodes[lt2a].right = t1;
      nodes[lt1a].right = t2;
    } while (--nu1);
    ;
    nu1 = w;
    do {
      lt1b = nodes[lt1b].right;
      lt2b = nodes[lt2b].right;
      register int t1 = nodes[lt1b].down;
      register int t2 = nodes[lt2b].down;
      nodes[lt2b].down = t1;
      nodes[lt1b].down = t2;
    } while (--nu1);
    ;
  } while (--q);
}
int main() {
  int n, m, q, datasize, i, i1, i2, i3, i4;
  int numbuffer[1024];
  scanf("%d %d %d", &n, &m, &q);
  datasize = fread(data, sizeof(char), sizeof(data), stdin);
  pdata = data;
  int nnn = n << 10;
  for (i = 0; i <= nnn; i += 1024) {
    int mmm = i | m;
    for (i1 = i, i2 = i | 1, i3 = i | 2, i4 = i | 3; i1 <= mmm;
         i1 += 4, i2 += 4, i3 += 4, i4 += 4) {
      nodes[i1].right = i1 + 1;
      nodes[i1].down = i1 + 1024;
      ;
      nodes[i2].right = i2 + 1;
      nodes[i2].down = i2 + 1024;
      ;
      nodes[i3].right = i3 + 1;
      nodes[i3].down = i3 + 1024;
      ;
      nodes[i4].right = i4 + 1;
      nodes[i4].down = i4 + 1024;
      ;
    }
  }
  char* pnumber = NULL;
  for (int r = 1, c = 1;;) {
    if (*pdata >= '0') {
      if (!pnumber) pnumber = pdata;
    } else {
      if (pnumber) {
        *(pnumber - 1) = (char)(pdata - pnumber);
        numbuffer[c] = pnumber - data;
        pnumber = NULL;
        if (++c > m) {
          memcpy(&pnum[(r << 10) | 1], &numbuffer[1], m << 2);
          if (++r > n) break;
          c = 1;
        }
      }
    }
    ++pdata;
  }
  main2(q);
  for (int i, r = 1; r <= n; ++r) {
    i = r << 10;
    for (int c = 1; c <= m; ++c) {
      i = nodes[i].right;
      numbuffer[c] = i;
    }
    for (int c = 1; c <= m; ++c) {
      char* pnumber = &data[pnum[numbuffer[c]]];
      fwrite(pnumber, (size_t) * (pnumber - 1), 1, stdout);
      putchar(' ');
    }
    putchar('\n');
  }
  return 0;
}