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

public class TaskE {
	
	public static Elem locate(int ii, int jj, Elem a) {
		Elem e = a;
		for (int i = 0; i < ii; i++) {
			e = e.d;
		}
		for (int j = 0; j < jj; j++) {
			e = e.r;
		}
		return e;
	}

	public static void main (String[] args) throws IOException {
		FastScanner fs = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
		
		int n = fs.nextInt();
		int m = fs.nextInt();
		int q = fs.nextInt();
		Elem[][] a = new Elem[n+2][m+2];
		for (int i = 0; i < n+2; i++) {
			for (int j = 0; j < m+2; j++) {
				a[i][j] = new Elem();
			}
		}
		for (int i = 0; i < n+2; i++) {
			for (int j = 0; j < m+1; j++) {
				a[i][j].r = a[i][j+1];
			}
		}
		for (int i = 0; i < n+1; i++) {
			for (int j = 0; j < m+2; j++) {
				a[i][j].d = a[i+1][j];
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				a[i][j].v = fs.nextInt();
			}
		}
		/*int c = 0;
		for (int i = 0; i < n+2; i++) {
			for (int j = 0; j < m+2; j++) {
				a[i][j].v = c;
				c++;
			}
		}	
		for (int i = 0; i < n+2; i++) {
			for (int j = 0; j < m+2; j++) {
				pw.format("%3d", a[i][j].v);				
			}
			pw.println();			
		}
*/
		for (int qq = 0; qq < q; qq++) {
			int i1 = fs.nextInt();
			int j1 = fs.nextInt();
			int i2 = fs.nextInt();
			int j2 = fs.nextInt();
			int ii = fs.nextInt();
			int jj = fs.nextInt();
			Elem e1u = locate(i1-1,    j1,      a[0][0]);
			Elem e1d = locate(i1-1+ii, j1,      a[0][0]);
			Elem e2u = locate(i2-1,    j2,      a[0][0]);
			Elem e2d = locate(i2-1+ii, j2,      a[0][0]);
			Elem e1l = locate(i1,      j1-1,    a[0][0]);
			Elem e1r = locate(i1,      j1-1+jj, a[0][0]);
			Elem e2l = locate(i2,      j2-1,    a[0][0]);
			Elem e2r = locate(i2,      j2-1+jj, a[0][0]);
			for (int j = 1; j <= jj; j++) {
				Elem e = e1u.d;
				e1u.d = e2u.d;
				e2u.d = e;
				e1u = e1u.r;
				e2u = e2u.r;
			}
		/*pw.println(qq+" u");
		for (int i = 0; i < n+1; i++) {
			for (int j = 0; j < m+1; j++) {
				pw.format("(%3d %3d %3d)", a[i][j].v, a[i][j].r.v, a[i][j].d.v);				
			}
			pw.println();			
		}*/				
			for (int j = 1; j <= jj; j++) {
				Elem e = e1d.d;
				e1d.d = e2d.d;
				e2d.d = e;
				e1d = e1d.r;
				e2d = e2d.r;				
			}
			for (int i = 1; i <= ii; i++) {
				Elem e = e1l.r;
				e1l.r = e2l.r;
				e2l.r = e;
				e1l = e1l.d;
				e2l = e2l.d;
			}
			for (int i = 1; i <= ii; i++) {
				Elem e = e1r.r;
				e1r.r = e2r.r;
				e2r.r = e;
				e1r = e1r.d;
				e2r = e2r.d;
			}
		}
		Elem e = a[0][0].r.d;		
		for (int i = 1; i <= n; i++) {
			Elem w = e;
			for (int j = 1; j <= m; j++) {
				pw.print(e.v);
				pw.print(" ");
				e = e.r;
			}
			pw.println();
			e = w.d;
		}		
		pw.close();		
	}

	static class Elem {
		int v;
		Elem r;
		Elem d;
	}

	static class FastScanner {
        BufferedReader reader;
        StringTokenizer tokenizer;        
        FastScanner(InputStream i) {
            reader = new BufferedReader(new InputStreamReader(i));
            tokenizer = new StringTokenizer("");
        }
        String next() throws IOException {
            while(!tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }        
    }
}