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;
template <typename T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%" PRId64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <typename T, typename... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <typename T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
template <typename T>
void _W(const vector<T> &x) {
  for (auto i = x.cbegin(); i != x.cend(); i++) {
    if (i != x.cbegin()) putchar(' ');
    _W(*i);
  }
}
void W() {}
template <typename T, typename... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
const int N = 1030;
int n, m, q, a[N][N], r[N * N], d[N * N];
inline int f(int x, int y) { return (x << 10) | y; }
inline int g(int x, int y) {
  int z = 0;
  while (x--) z = d[z];
  while (y--) z = r[z];
  return z;
}
int main() {
  R(n, m, q);
  for (int i = (1); i <= int(n); i++)
    for (int j = (1); j <= int(m); j++) R(a[i][j]);
  for (int i = (0); i <= int(n); i++)
    for (int j = 0; j < int(m); j++) r[f(i, j)] = f(i, j + 1);
  for (int i = (0); i <= int(m); i++)
    for (int j = 0; j < int(n); j++) d[f(j, i)] = f(j + 1, i);
  while (q--) {
    int x1, y1, x2, y2, h, w;
    R(x1, y1, x2, y2, h, w);
    int r1 = g(x1 - 1, y1 - 1), d1 = r1;
    int r2 = g(x2 - 1, y2 - 1), d2 = r2;
    for (int i = 0; i < int(h); i++) swap(r[d1 = d[d1]], r[d2 = d[d2]]);
    for (int i = 0; i < int(w); i++) swap(d[r1 = r[r1]], d[r2 = r[r2]]);
    for (int i = 0; i < int(w); i++) swap(d[d1 = r[d1]], d[d2 = r[d2]]);
    for (int i = 0; i < int(h); i++) swap(r[r1 = d[r1]], r[r2 = d[r2]]);
  }
  for (int i = (1); i <= int(n); i++) {
    int p = f(i, 0);
    for (int j = (1); j <= int(m); j++) {
      p = r[p];
      printf("%d%c", a[p >> 10][p & 0x3FF], j == m ? '\n' : ' ');
    }
  }
  return 0;
}