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 CF367E
{
	static class Node
	{
		Node d,r;
		int k;
	}
	static Node[][] x;
	static Node find(int r,int c)
	{
		int i=0;
		Node t=x[0][0];
		for(;i<r;i++)
			t=t.d;
		for(i=0;i<c;i++)
			t=t.r;
		return t;
	}
	public static void main(String args[])
	{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		/*------------------------------My Code starts here------------------------------*/
		int i=0,j,n=in.nextInt(),m=in.nextInt(),q=in.nextInt(),a,b,c,d,h,w;
		x=new Node[n+2][m+2];
		for(i=0;i<x.length;i++)
		{
			for(j=0;j<x[0].length;j++)
				x[i][j]=new Node();
		}
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=m;j++)
				x[i][j].k=in.nextInt();
		}
		for(i=0;i<n+2;i++)
		{
			for(j=0;j<m+2;j++)
			{
				if(i<n+1)
					x[i][j].d=x[i+1][j];
				if(j<m+1)
					x[i][j].r=x[i][j+1];
			}
		}
		while(q-->0)
		{
			a=in.nextInt();
			b=in.nextInt();
			c=in.nextInt();
			d=in.nextInt();
			h=in.nextInt();
			w=in.nextInt();
			Node t1=find(a, b-1);
			Node t2=find(a, b+w-1);
			Node t3=find(c, d-1);
			Node t4=find(c, d+w-1);
			for(i=0;i<h;i++)
			{
				Node k1=t1.r;
				Node k2=t2.r;
				Node k3=t3.r;
				Node k4=t4.r;
				t1.r=k3;
				t3.r=k1;
				t2.r=k4;
				t4.r=k2;
				t1=t1.d;
				t2=t2.d;
				t3=t3.d;
				t4=t4.d;
			}
			t1=find(a-1, b);
			t2=find(a+h-1, b);
			t3=find(c-1, d);
			t4=find(c+h-1, d);
			for(i=0;i<w;i++)
			{
				Node k1=t1.d;
				Node k2=t2.d;
				Node k3=t3.d;
				Node k4=t4.d;
				t1.d=k3;
				t3.d=k1;
				t2.d=k4;
				t4.d=k2;
				t1=t1.r;
				t2=t2.r;
				t3=t3.r;
				t4=t4.r;
			}
		}
		Node t=x[1][0],z;
		for(i=0;i<n;i++)
		{
			z=t;
			for(j=0;j<m;j++)
			{
				z=z.r;
				out.print(z.k+" ");
			}
			t=t.d;
			out.println();
		}
		out.close();
		/*------------------------------The End------------------------------------------*/
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}