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 bad(string mes = "Impossible") {
  cout << mes;
  exit(0);
}
template <typename... T>
void shit(T&... x) {}
template <typename... T>
void dec(T&... x) {
  shit(--x...);
}
template <typename... T>
void inc(T&... x) {
  shit(++x...);
}
template <typename T>
string bin(T x, int st = 2) {
  string ans = "";
  while (x > 0) {
    ans += char('0' + x % st);
    x /= st;
  }
  reverse(ans.begin(), ans.end());
  return ans.empty() ? "0" : ans;
}
template <typename T>
T input() {
  T ans = 0, m = 1;
  char c = ' ';
  while (!((c >= '0' && c <= '9') || c == '-')) {
    c = getchar();
  }
  if (c == '-') m = -1, c = getchar();
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + (c - '0'), c = getchar();
  }
  return ans * m;
}
template <typename T>
void read(T& a) {
  a = input<T>();
}
template <typename T>
void read(T& a, T& b) {
  read(a), read(b);
}
template <typename T>
void read(T& a, T& b, T& c) {
  read(a, b), read(c);
}
template <typename T>
void read(T& a, T& b, T& c, T& d) {
  read(a, b), read(c, d);
}
const int inf = 2e9;
const double eps = 1e-9;
const int maxn = 2e3 + 5, base = 1e9 + 7;
const long long llinf = 1e18 + 1;
template <typename T>
T binpow(T n, T second) {
  if (second <= 0) return 1LL;
  if (second % 2 == 0) {
    T b = binpow(n, second / 2);
    return (1LL * b * b) % base;
  } else {
    return (1LL * binpow(n, second - 1) * n) % base;
  }
}
struct node {
  node *l, *r, *u, *d;
  int x, y;
  node() {}
  node(int x, int y) : x(x), y(y) { l = 0, r = 0, u = 0, d = 0; }
};
node* to_build[maxn][maxn];
int a[maxn][maxn];
void move(node*& a, int x, int y) {
  if (x >= 0)
    while (x--) a = a->d;
  else
    while (x++) a = a->u;
  if (y >= 0)
    while (y--) a = a->r;
  else
    while (y++) a = a->l;
}
void print(int n, int m) {
  node* pos = to_build[0][0];
  while (pos->l != 0) pos = pos->l;
  while (pos->u != 0) pos = pos->u;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%d ", a[pos->x][pos->y]);
      if (j != m - 1) move(pos, 0, 1);
    }
    puts("");
    move(pos, 0, -(m - 1));
    if (i != n - 1) move(pos, 1, 0);
  }
}
int main() {
  int n, m, q;
  read(n, m, q);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      read(a[i][j]);
      to_build[i][j] = new node(i, j);
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (i) to_build[i][j]->u = to_build[i - 1][j];
      if (j) to_build[i][j]->l = to_build[i][j - 1];
      if (i != n - 1) to_build[i][j]->d = to_build[i + 1][j];
      if (j != m - 1) to_build[i][j]->r = to_build[i][j + 1];
    }
  while (q--) {
    int x1, y1, x2, y2, h, w;
    read(x1, y1, x2, y2);
    read(h, w);
    dec(x1, y1, x2, y2);
    node* first = to_build[0][0];
    while (first->l != 0) first = first->l;
    while (first->u != 0) first = first->u;
    node* second = first;
    move(first, x1, y1);
    move(second, x2, y2);
    for (int i = 0; i < h; i++) {
      node* fl = first->l;
      node* sl = second->l;
      if (fl) fl->r = second;
      if (sl) sl->r = first;
      first->l = sl;
      second->l = fl;
      if (i != h - 1) {
        move(first, 1, 0);
        move(second, 1, 0);
      }
    }
    for (int i = 0; i < w; i++) {
      node* fd = first->d;
      node* sd = second->d;
      if (fd) fd->u = second;
      if (sd) sd->u = first;
      first->d = sd;
      second->d = fd;
      if (i != w - 1) {
        move(first, 0, 1);
        move(second, 0, 1);
      }
    }
    for (int i = 0; i < h; i++) {
      node* fr = first->r;
      node* sr = second->r;
      if (fr) fr->l = second;
      if (sr) sr->l = first;
      first->r = sr;
      second->r = fr;
      if (i != h - 1) {
        move(first, -1, 0);
        move(second, -1, 0);
      }
    }
    for (int i = 0; i < w; i++) {
      node* fu = first->u;
      node* su = second->u;
      if (fu) fu->d = second;
      if (su) su->d = first;
      first->u = su;
      second->u = fu;
      if (i != w - 1) {
        move(first, 0, -1);
        move(second, 0, -1);
      }
    }
  }
  print(n, m);
  return 0;
}