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:
//  package CF;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), m = sc.nextInt(), q = sc.nextInt();
		Node [][] mat = new Node[n+1][m+1];
		mat[0][0] = new Node(0);
		for (int i = 1; i <= n; i++) {
			mat[i-1][0].down = mat[i][0] = new Node(0);
		}
		for (int i = 1; i <= m; i++) {
			mat[0][i-1].right = mat[0][i] = new Node(0);
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				mat[i-1][j].down = mat[i][j-1].right = mat[i][j] = new Node(sc.nextInt());
			}
		}
		while(q-->0){
			int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt(), h = sc.nextInt(), w = sc.nextInt();
			Node [] x1 = getRow(mat, w, a-1, b), xx1 = getRow(mat, w, a+h-1, b);
			Node [] x2 = getRow(mat, w, c-1, d), xx2 = getRow(mat, w, c+h-1, d);
			Node [] y1 = getCol(mat, h, a, b-1), yy1 = getCol(mat, h, a, b+w-1);
			Node [] y2 = getCol(mat, h, c, d-1), yy2 = getCol(mat, h, c, d+w-1);
			
			swapD(x1, x2, w);
			swapD(xx1, xx2, w);
			swapR(y1, y2, h);
			swapR(yy1, yy2, h);
		}
		int [][] ans = new int[n][m];
		for (int j = 1; j <= m; j++) {
			Node cur = mat[0][j].down;
			for (int i = 1; i <= n; i++) {
				ans[i-1][j-1] = cur.val;
				cur = cur.down;
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < ans.length; i++) {
			for (int j = 0; j < ans[i].length; j++) {
				sb.append(ans[i][j] + " ");
			}
			sb.append("\n");
		}
		out.print(sb);
		out.flush();
		out.close();
	}
	static Node [] getRow(Node [][] mat, int w, int a, int b){
		Node [] ret = new Node[w];
		Node cur = mat[0][b];
		while(a-->0){
			cur = cur.down;
		}
		for (int i = 0; i < w; i++) {
			ret[i] = cur;
			cur = cur.right;
		}
		return ret;
	}
	static Node [] getCol(Node [][] mat, int h, int a, int b){
		Node [] ret = new Node[h];
		Node cur = mat[0][b];
		while(a-->0){
			cur = cur.down;
		}
		for (int i = 0; i < h; i++) {
			ret[i] = cur;
			cur = cur.down;
		}
		return ret;
	}
	static void swapR(Node [] x, Node [] y, int len){
		for (int i = 0; i < len; ++i) {
			Node d1 = x[i].right, d2 = y[i].right;
			x[i].right = d2;
			y[i].right = d1;
		}
	}
	static void swapD(Node [] x, Node [] y, int len){
		for (int i = 0; i < len; ++i) {
			Node d1 = x[i].down, d2 = y[i].down;
			x[i].down = d2;
			y[i].down = d1;
		}
	}
	
	static class Node {
		int val;
		Node right, down;
		public Node(int v){
			val = v;
		}
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}