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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class E706 {
	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;
	
	public String nextToken() throws IOException {
	    while (in == null || !in.hasMoreTokens()) {
	        in = new StringTokenizer(br.readLine());
	    }
	    return in.nextToken();
	}
	
	public int nextInt() throws IOException {
	    return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
	    return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
	    return Double.parseDouble(nextToken());
	}
	
	public void solve() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        int rows = nextInt();
        int cols = nextInt();
        int tests = nextInt();
        
        Node [][] nodes = new Node[rows+2][cols+2];
        for(int i = 1 ; i <= rows ; i++)
        	for(int j = 1 ; j <= cols ; j++) {
        		int value = nextInt();
        		nodes[i][j] = new Node(value);
        	}
        for(int i = 0; i <= rows+1; i++) {
        	nodes[i][0] = new Node(0);
        	nodes[i][cols+1] = new Node(0);
        }
        for(int i = 0 ; i <= cols+1; i++) {
        	nodes[0][i] = new Node(0);
        	nodes[rows+1][i] = new Node(0);
        }
        
        for(int i = 0 ; i <= rows+1; i++) {
        	for(int j = 0 ; j<=cols+1; j++) {
        		if(i-1>=0) {
        			nodes[i][j].up = nodes[i-1][j];
        		}
        		if(i+1 <= rows+1) {
        			nodes[i][j].down = nodes[i+1][j];
        		}
        		if(j - 1 >= 0) {
        			nodes[i][j].left = nodes[i][j-1];
        		}
        		if(j + 1 <= cols+1) {
        			nodes[i][j].right = nodes[i][j+1];
        		}
        	}
        }

        for(int i = 0 ; i < tests; i++) {
        	int x1 = nextInt();
        	int y1 = nextInt();
        	int x2 = nextInt();
        	int y2 = nextInt();
        	int height = nextInt();
        	int width = nextInt();
        	
        	Node vertex1 = nodes[0][0];
        	while(x1-->0)
        		vertex1 = vertex1.down;
        	while(y1-->0)
        		vertex1 = vertex1.right;
        	
        	Node vertex2 = nodes[0][0];
        	while(x2-->0)
        		vertex2 = vertex2.down;
        	while(y2-->0)
        		vertex2 = vertex2.right;
        	
        	for(int k = 0 ; k < width; k++)
        	{
        		swapUp(vertex1,vertex2);
        		if(k != width-1) {
        			vertex1 = vertex1.right;
        			vertex2 = vertex2.right;
        		}
        	}
        	for(int k = 0 ; k < height; k++)
        	{
        		swapRight(vertex1,vertex2);
        		if(k != height-1) {
        			vertex1 = vertex1.down;
        			vertex2 = vertex2.down;
        		}
        	}
        	for(int k = 0 ; k < width; k++)
	        {
	        	swapDown(vertex1,vertex2);
	        	if(k != width-1) {
	        		vertex1 = vertex1.left;
	        		vertex2 = vertex2.left;
	        	}
	        }
			for(int k = 0 ; k < height; k++)
	        {
	        	swapLeft(vertex1,vertex2);
	        	if(k != height-1) {
	        		vertex1 = vertex1.up;
	        		vertex2 = vertex2.up;
	        	}
	        }
        }
        Node first = nodes[0][0].right.down;
        for(int k = 0 ; k < rows; k++) {
        	Node current = first;
        	for(int j = 0 ; j < cols ; j++) {
        		out.print(current.value+" ");
        		current = current.right;
        	}
        	out.println();
        	first = first.down;
        }
        out.close();
     }
	public void swapUp(Node a, Node b) {
		a.up.down = b;
		b.up.down = a;
		Node temp = a.up;
		a.up = b.up;
		b.up = temp;
	}
	public void swapRight(Node a, Node b) {
		a.right.left = b;
		b.right.left = a;
		Node temp = a.right;
		a.right = b.right;
		b.right = temp;
	}
	public void swapDown(Node a, Node b) {
		a.down.up = b;
		b.down.up = a;
		Node temp = a.down;
		a.down = b.down;
		b.down = temp;		
	}
	public void swapLeft(Node a, Node b) {
		a.left.right = b;
		b.left.right = a;
		Node temp = a.left;
		a.left = b.left;
		b.left = temp;		
	}
	public static void main (String [] args) throws IOException {
		new E706().solve();
	}
	
	class Node {
		Node up;
		Node down;
		Node left;
		Node right;
		int value;
		
		public Node(int value) {
			this.value = value;
		}
	}
}