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:
// CodeForces Round 367 -- slowe

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class E367 {
	static Node[] left;
	public static void main(String[] args) throws Exception {
		FastScanner in = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int r = in.nextInt(), c = in.nextInt(), q = in.nextInt();
		Node[][] A = new Node[r][c];
		for(int i = 0; i < r; i++)
			for(int j = 0; j < c; j++) {
				A[i][j] = new Node(in.nextInt());
				if(i > 0) {
					A[i][j].n = A[i-1][j];
					A[i-1][j].s = A[i][j];
				}
				else { // north border
					A[i][j].n = new Node(-j);
					A[i][j].n.s = A[i][j];
				}
				
				if(j > 0) {
					A[i][j].w = A[i][j-1];
					A[i][j-1].e = A[i][j];
				}
				
				if(i+1 == r) { // south border
					A[i][j].s = new Node(-j);
					A[i][j].s.n = A[i][j];
				}
				
				if(j+1 == c) { // east border
					A[i][j].e = new Node(-i);
					A[i][j].e.w = A[i][j];
				}
			}
		
		left = new Node[r];
		for(int i = 0; i < r; i++) {
			left[i] = new Node(-i);
			left[i].e = A[i][0];
			A[i][0].w = left[i];
		}
		
		while(q-->0) {
			int a = in.nextInt()-1, b = in.nextInt()-1,
				x = in.nextInt()-1, y = in.nextInt()-1,
				h = in.nextInt(), w = in.nextInt();
			
			Node    foo = find(a, b),
					bar = find(x, y);
			
			for(int i = 0; i < w; i++) {
				Node tempFoo = foo.n, tempBar = bar.n;
				foo.n = tempBar;
				tempBar.s = foo;
				bar.n = tempFoo;
				tempFoo.s = bar;
				foo = foo.e;
				bar = bar.e;
			}
			
			// correct overstepping
			foo = foo.w;
			bar = bar.w;
			for(int i = 0; i < h; i++) {
				Node tempFoo = foo.e, tempBar = bar.e;
				foo.e = tempBar;
				tempBar.w = foo;
				bar.e = tempFoo;
				tempFoo.w = bar;
				foo = foo.s;
				bar = bar.s;
			}
			foo = foo.n;
			bar = bar.n;
			
			for(int i = 0; i < w; i++) {
				Node tempFoo = foo.s, tempBar = bar.s;
				foo.s = tempBar;
				tempBar.n = foo;
				bar.s = tempFoo;
				tempFoo.n = bar;
				foo = foo.w;
				bar = bar.w;
			}
			foo = foo.e;
			bar = bar.e;
			
			for(int i = 0; i < h; i++) {
				Node tempFoo = foo.w, tempBar = bar.w;
				foo.w = tempBar;
				tempBar.e = foo;
				bar.w = tempFoo;
				tempFoo.e = bar;
				foo = foo.n;
				bar = bar.n;
			}
		}
		
		for(int i = 0; i < r; i++) {
			Node foo = left[i].e;
			for(int j = 0; j < c; j++) {
				pw.print(foo.val);
				pw.append(' ');
				foo = foo.e;
			}
			pw.println();
		}
		
		pw.flush();
		pw.close();
	}
	
	static Node find(int x, int y) {
		Node foo = left[x].e;
		while(y-->0)
			foo = foo.e;
		return foo;
	}
	
	static class Node {
		int val;
		Node n, e, s, w;
		
		public Node(int num) {
			val = num;
		}
	}
	
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer("");
		}
		
		String next() throws Exception {
			while(!st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		
		int nextInt() throws Exception {
			return Integer.parseInt(next());
		}
	}
}