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.*;
import java.math.BigInteger;
import java.security.SecureRandom;
/*


 */
public class e 
{
	public static void main(String[] arg) throws IOException
	{
		new e();
	}
	int n, m;
	Pair[][] vs;
	int LEFT = 0;
	int RIGHT = 1;
	int UP = 2;
	int DOWN = 3;
	void swap(Pair a, Pair b, int op)
	{
		if(op == LEFT)
		{
			Pair l1 = a.left;
			Pair l2 = b.left;
			if(l1 != null) l1.right = b;
			if(l2 != null) l2.right = a;
			
			Pair temp = a.left;
			a.left = b.left;
			b.left = temp;
		}
		if(op == RIGHT)
		{
			Pair r1 = a.right;
			Pair r2 = b.right;
			if(r1 != null) r1.left = b;
			if(r2 != null) r2.left = a;
			
			Pair temp = a.right;
			a.right = b.right;
			b.right = temp;
		}
		if(op == UP)
		{
			Pair u1 = a.up;
			Pair u2 = b.up;
			if(u1 != null) u1.down = b;
			if(u2 != null) u2.down = a;
			
			Pair temp = a.up;
			a.up = b.up;
			b.up = temp;
		}
		if(op == DOWN)
		{
			Pair d1 = a.down;
			Pair d2 = b.down;
			if(d1 != null) d1.up = b;
			if(d2 != null) d2.up = a;
			
			Pair temp = a.down;
			a.down = b.down;
			b.down = temp;
		}
	}
	public e() throws IOException
	{
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		n = in.nextInt();
		m = in.nextInt();
		int q = in.nextInt();
		vs = new Pair[n][m];
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m; j++)
			{
				vs[i][j] = new Pair(in.nextInt());
			}
		}
		Pair[] starts = new Pair[n];
		for(int i = 0; i < n; i++)
		{
			starts[i] = new Pair(-1);
			starts[i].right = vs[i][0];
			vs[i][0].left = starts[i];
		}
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m; j++)
			{
				if(i-1 >= 0) vs[i][j].up = vs[i-1][j];
				if(j-1 >= 0) vs[i][j].left = vs[i][j-1];
				if(i+1 < n) vs[i][j].down = vs[i+1][j];
				if(j+1 < m) vs[i][j].right = vs[i][j+1];
			}
		}
		for(int qq = 0; qq < q; qq++)
		{
			int a = in.nextInt()-1;
			int b = in.nextInt()-1;
			int c = in.nextInt()-1;
			int d = in.nextInt()-1;
			int h = in.nextInt();
			int w = in.nextInt();
			
			Pair op1 = get(starts, a, b);
			Pair op2 = get(starts, c, d);
			Pair op3 = get(starts, a, b+w-1);
			Pair op4 = get(starts, c, d+w-1);
			
			Pair op5 = get(starts, a, b);
			Pair op6 = get(starts, c, d);
			Pair op7 = get(starts, a+h-1, b);
			Pair op8 = get(starts, c+h-1, d);
			for(int i = 0; i < h; i++)
			{
				swap(op1, op2, LEFT);
				swap(op3, op4, RIGHT);
				op1 = op1.down;
				op2 = op2.down;
				op3 = op3.down;
				op4 = op4.down;
			}
			for(int i = 0; i < w; i++)
			{
				swap(op5, op6, UP);
				swap(op7, op8, DOWN);
				op5 = op5.right;
				op6 = op6.right;
				op7 = op7.right;
				op8 = op8.right;
			}
		}
		for(int i = 0; i < n; i++)
		{
			for(Pair cur = starts[i].right; cur != null; cur = cur.right)
			{
				out.print(cur + " ");
			}
			out.println();
		}
		in.close(); out.close();
	}
	Pair get(Pair[] start, int r, int c)
	{
		Pair ret = start[r].right;
		for(int i=  0; i < c; i++) ret = ret.right;
		return ret;
	}
	class Pair
	{
		int v;
		Pair up;
		Pair down;
		Pair left;
		Pair right;
		public Pair(int val)
		{
			v = val;
			up = null;
			down = null;
			left = null;
			right = null;
		}
		public String toString()
		{
			return ""+v;
		}
		public String print()
		{
			String ret = ""+v;
			if(up != null) ret += ' '+up.toString();
			else ret += " null";
			
			if(down != null) ret += ' '+down.toString();
			else ret += " null";
			
			if(left != null) ret += ' '+left.toString();
			else ret += " null";
			
			if(right != null) ret += ' '+right.toString();
			else ret += " null";
			
			return ret;
		}
	}
	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 long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
		public void close() throws IOException
		{
			br.close();
		}
	}
}