Problem D: Matrix Swapping

Problem D: Matrix Swapping

Time Limit: 2 Sec  Memory Limit: 512 MB
Submit: 652  Solved: 132
[Submit][Status][Web Board]

Description

You are given a n*m size matrix A. The matrix has n rows and m columns. The element at the i-th row and j-th column is Ai,j. Consider two sub-matrices in it, these two sub-matrices are defined by (i) the coordinates of the top left elements of these two sub-matrices are (x1, y1) and (x2, y2), respectively, and (ii) the size of each sub-matrix is l1*l2. The matrix swapping operation is swapping every elements pair in these two sub-matrices. For example, for all i (0 ≤ i < l1) and j (0 ≤ j < l2), swap Ax1+i,y1+j and Ax2+i,y2+j

We guarantee these two swapping sub-matrices are not adjacent or overlapping.

What the result matrix is after applied q times matrix swapping operations?

Input

The first line contains three integers n, m, q (2 ≤ n , m ≤ 1000, q ≤10000), denotes the size of matrix A and the total times of swapping operation.

It follows n rows, each of row includes m integers, which denotes the n*m matrix A. (1 ≤ Aij ≤ 1000)

Then it follows q lines, each line includes six integers x1, y1, x2, y2, l1, l2.

Output

The result matrix A with n rows, m columns after q times swapping operations.

Sample Input

4 2 1
1 1
1 1
2 2
2 2
2 1 4 1 1 2

Sample Output

1 1 
2 2 
2 2 
1 1

HINT

[Submit][Status]