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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class E {

	private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	private static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	
	private static class V {
		public int val;
		public V right;
		public V down;
		public V get(int dr, int dc) {
			V ret = this;
			while (dr-- > 0)
				ret = ret.down;
			while (dc-- > 0)
				ret = ret.right;
			return ret;
		}
	}
	
	private static void update(V rect1, V rect2, int length, int dr, int dc, boolean updateR, boolean updateC) {
		while (length-- > 0) {
			if (updateR) {
				V tmp = rect1.down;
				rect1.down = rect2.down;
				rect2.down = tmp;
			}
			if (updateC) {
				V tmp = rect1.right;
				rect1.right = rect2.right;
				rect2.right = tmp;
			}
			rect1 = rect1.get(dr, dc);
			rect2 = rect2.get(dr, dc);
		}
	}
	
	public static void main(String[] args) throws IOException {
		String[] s = in.readLine().split(" ");
		int n = Integer.parseInt(s[0]);
		int m = Integer.parseInt(s[1]);
		int q = Integer.parseInt(s[2]);
		V[][] vs = new V[n + 1][m + 1];
		for (int i = n; i >= 0; --i)
			for (int j = m; j >= 0; --j) {
				vs[i][j] = new V();
				if (i < n)
					vs[i][j].down = vs[i + 1][j];
				if (j < m)
					vs[i][j].right = vs[i][j + 1];
			}
		for (int i = 1; i <= n; ++i) {
			s = in.readLine().split(" ");
			for (int j = 1; j <= m; ++j)
				vs[i][j].val = Integer.parseInt(s[j - 1]);
		}
		V corner = vs[0][0];
		while (q-- > 0) {
			s = in.readLine().split(" ");
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			int c = Integer.parseInt(s[2]);
			int d = Integer.parseInt(s[3]);
			int h = Integer.parseInt(s[4]);
			int w = Integer.parseInt(s[5]);
			V topLeft1 = corner.get(a - 1, b - 1);
			V topLeft2 = corner.get(c - 1, d - 1);
			V topRight1 = corner.get(a, b + w - 1);
			V topRight2 = corner.get(c, d + w - 1);
			V bottomLeft1 = corner.get(a + h - 1, b);
			V bottomLeft2 = corner.get(c + h - 1, d);
			update(topLeft1.right, topLeft2.right, w, 0, 1, true, false);
			update(topLeft1.down, topLeft2.down, h, 1, 0, false, true);
			update(topRight1, topRight2, h, 1, 0, false, true);
			update(bottomLeft1, bottomLeft2, w, 0, 1, true, false);
		}
		for (int i = 1; i <= n; ++i) {
			V base = corner.get(i, 1);
			for (int j = 1; j <= m; ++j) {
				out.print(base.val + " ");
				base = base.get(0, 1);
			}
			out.println();
		}
		out.flush();
	}

}