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.util.*;
import java.io.*;
/*

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



4 4 1
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
1 1 3 3 2 2


4 4 1
10 11 12 13
14 15 16 17
18 19 20 21
22 23 24 25
1 1 3 3 2 2



 */
public class E2 {
	static final int up = 0;
	static final int down = 1;
	static final int left = 2;
	static final int right = 3;
	static final int val = 4;
	static int[][] refs;
	
	public static void main(String[] args) throws IOException {
		
		FastScanner qwe = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int R = qwe.nextInt();
		int C = qwe.nextInt();
		int q = qwe.nextInt();
		
		
		int[][] ori = new int[R+2][C+2];
		int dex = 0;
		refs = new int[5][(R+2)*(C+2)];
		
		for (int i = 0; i < ori.length; i++) {
			for (int j = 0; j < ori[0].length; j++) {
				
				ori[i][j] = dex++;
				
				if(i == 0 || j == 0 || i == R+1 || j == C+1){
					refs[val][ori[i][j]] = -1;
				}
				else{
					refs[val][ori[i][j]]  = qwe.nextInt();
				}
			}
		}
		
		for (int i = 0; i < ori.length; i++) {
			for (int j = 0; j < ori[0].length; j++) {
				if(i == 0 || j == 0 || i == R+1 || j == C+1){
				}
				else{
					
					int at = ori[i][j];
					refs[left][at] = ori[i][j-1];
					refs[right][ori[i][j-1]] = at;
					
					refs[right][at] = ori[i][j+1];
					refs[left][ori[i][j+1]] = at;
					
					refs[up][at] = ori[i-1][j];
					refs[down][ori[i-1][j]] = at;
					
					refs[down][at] = ori[i+1][j];
					refs[up][ori[i+1][j]] = at;
					
				}
			}
		}
		
		refs[right][0] = ori[0][1];
		
		while(q-->0){
			
			int a = qwe.nextInt();
			int b = qwe.nextInt();
			int c = qwe.nextInt();
			int d = qwe.nextInt();
			int h = qwe.nextInt();
			int w = qwe.nextInt();
			
			int fi= walk(a,b);
			int se = walk(c,d);
			
			//System.out.println(se);
			//System.out.println(fi);
			
			
			//sswap(fi,se,left,right);
			
			sswap(fi,se,up,down);
			
			
			for(int i =0;i < w-1; i++){
				fi = refs[right][fi];
				se = refs[right][se];
				
				sswap(fi,se,up,down);
				
			}
			
			sswap(fi,se,right,left);
			
			
			for(int i =0; i < h-1; i++){
				fi = refs[down][fi];
				se = refs[down][se];
				
				sswap(fi,se,right,left);
				
			}
			
			sswap(fi,se,down,up);
			
			for(int i =0;i < w-1; i++){
				fi = refs[left][fi];
				se = refs[left][se];
				
				sswap(fi,se,down,up);
			}
			
			sswap(fi,se,left,right);
			
			for(int i =0; i < h-1; i++){
				fi = refs[up][fi];
				se = refs[up][se];
				
				sswap(fi,se,left,right);
				
			}
			
			
			
		}
		
		
		int at = refs[right][0];
		at = refs[down][at];
		
		
		for(int i =0; i < R; i++){
			int next = refs[down][at];
			for(int j =0; j < C; j++){
				out.print(refs[val][at] +" ");
				at = refs[right][at];
			}
			out.println();
			at = next;
		}
		out.close();
		
	}
	
	static void sswap(int fi, int se, int d1, int d2){
		
		refs[d2][refs[d1][fi]] = se;
		refs[d2][refs[d1][se]] = fi;
		
		int temp = refs[d1][fi];
		refs[d1][fi] = refs[d1][se];
		refs[d1][se] = temp;
		
	}
	
	static int walk(int r, int c){
		int at = refs[right][0];
		at = refs[down][at];
		int cr = 1;
		int cc = 1;
		
		//System.out.println("walking start " + at);
		
		while(cr < r){
			cr++;
			at = refs[down][at];
			//System.out.println("walked down " + at);
		}
		
		while(cc < c){
			cc++;
			at = refs[right][at];
		}
		
		return at;
		
	}
	
	static class FastScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public String next() throws IOException
		{
			while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}
		public void close() throws IOException
		{
			br.close();
		}
	}


}