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 JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskE {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int height = in.nextInt();
			int width = in.nextInt();
			int numQueries = in.nextInt();
			Cell[][] a = new Cell[height + 2][width + 2];
			for (int r = 0; r < height + 2; r++) {
				for (int c = 0; c < width + 2; c++) {
					a[r][c] = new Cell();
				}
			}
			for (int r = 1; r <= height; r++) {
				for (int c = 1; c <= width; c++) {
					a[r][c].val = in.nextInt();
				}
			}
			for (int r = 0; r < height + 2; r++) {
				for (int c = 0; c < width + 2; c++) {
					if (r > 0) {
						a[r][c].u = a[r - 1][c];
						a[r - 1][c].d = a[r][c];
					}
					if (c > 0) {
						a[r][c].l = a[r][c - 1];
						a[r][c - 1].r = a[r][c];
					}
				}
			}
			for (int query = 0; query < numQueries; query++) {
				int r1 = in.nextInt();
				int c1 = in.nextInt();
				int r2 = in.nextInt();
				int c2 = in.nextInt();
				int h = in.nextInt();
				int w = in.nextInt();
				Cell cur1 = getCell(a, r1, c1);
				Cell cur2 = getCell(a, r2, c2);
				Cell cur3 = getCell(a, r1, c1 + w - 1);
				Cell cur4 = getCell(a, r2, c2 + w - 1);
				for (int dr = 0; dr < h; dr++) {
					Cell R1 = cur1;
					Cell R2 = cur2;
					Cell L1 = R1.l;
					Cell L2 = R2.l;
					R1.l = L2;
					R2.l = L1;
					L1.r = R2;
					L2.r = R1;

					L1 = cur3;
					L2 = cur4;
					R1 = L1.r;
					R2 = L2.r;
					R1.l = L2;
					R2.l = L1;
					L1.r = R2;
					L2.r = R1;

					cur1 = cur1.d;
					cur2 = cur2.d;
					cur3 = cur3.d;
					cur4 = cur4.d;
				}

				cur1 = getCell(a, r1, c1);
				cur2 = getCell(a, r2, c2);
				cur3 = getCell(a, r1 + h - 1, c1);
				cur4 = getCell(a, r2 + h - 1, c2);
				for (int dc = 0; dc < w; dc++) {
					Cell D1 = cur1;
					Cell D2 = cur2;
					Cell U1 = D1.u;
					Cell U2 = D2.u;
					U1.d = D2;
					U2.d = D1;
					D1.u = U2;
					D2.u = U1;

					U1 = cur3;
					U2 = cur4;
					D1 = U1.d;
					D2 = U2.d;
					U1.d = D2;
					U2.d = D1;
					D1.u = U2;
					D2.u = U1;

					cur1 = cur1.r;
					cur2 = cur2.r;
					cur3 = cur3.r;
					cur4 = cur4.r;
				}
			}

			for (int r = 1; r <= height; r++) {
				Cell cur = a[r][0];
				for (int c = 1; c <= width; c++) {
					cur = cur.r;
					if (c > 1) {
						out.print(" ");
					}
					if (cur.val == 0) {
						throw new AssertionError();
					}
					out.print(cur.val);
				}
				out.println();
			}
		}

		private Cell getCell(Cell[][] a, int r, int c) {
			Cell res = a[0][0];
			for (int i = 0; i < r; i++) {
				res = res.d;
			}
			for (int i = 0; i < c; i++) {
				res = res.r;
			}
			return res;
		}

		class Cell {
			Cell u;
			Cell l;
			Cell d;
			Cell r;
			int val;

		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}