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

/**
 * @author Don Li
 */
public class WorkingRoutine {
    
    int u, v;
    
    void solve() {
        int n = in.nextInt(), m = in.nextInt(), q = in.nextInt();
        int[][] A = new int[n][m];
        for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) A[i][j] = in.nextInt();
        
        int[] R = new int[(n + 1) * (m + 1)], D = new int[(n + 1) * (m + 1)];
        Arrays.fill(R, -1);
        Arrays.fill(D, -1);
        
        for (int i = 0; i < n + 1; i++) {
            for (int j = 0; j < m + 1; j++) {
                if (j + 1 < m + 1) R[i * (m + 1) + j] = i * (m + 1) + j + 1;
                if (i + 1 < n + 1) D[i * (m + 1) + j] = (i + 1) * (m + 1) + j;
            }
        }
        
        while (q-- > 0) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), d = in.nextInt();
            int h = in.nextInt(), w = in.nextInt();
            
            u = (a - 1) * (m + 1);
            for (int i = 0; i < b; i++) u = R[u];
            v = (c - 1) * (m + 1);
            for (int i = 0; i < d; i++) v = R[v];
            for (int i = 0; i < w; i++) {
                swap(D, u, v);
                u = R[u];
                v = R[v];
            }
            
            u = (a - 1 + h) * (m + 1);
            for (int i = 0; i < b; i++) u = R[u];
            v = (c - 1 + h) * (m + 1);
            for (int i = 0; i < d; i++) v = R[v];
            for (int i = 0; i < w; i++) {
                swap(D, u, v);
                u = R[u];
                v = R[v];
            }
            
            u = b - 1;
            for (int i = 0; i < a; i++) u = D[u];
            v = d - 1;
            for (int i = 0; i < c; i++) v = D[v];
            for (int i = 0; i < h; i++) {
                swap(R, u, v);
                u = D[u];
                v = D[v];
            }
            
            u = b - 1 + w;
            for (int i = 0; i < a; i++) u = D[u];
            v = d - 1 + w;
            for (int i = 0; i < c; i++) v = D[v];
            for (int i = 0; i < h; i++) {
                swap(R, u, v);
                u = D[u];
                v = D[v];
            }
        }
        
        for (int i = 1; i < n + 1; i++) {
            u = i * (m + 1);
            for (int j = 1; j < m + 1; j++) {
                u = R[u];
                int x = u / (m + 1), y = u % (m + 1);
                if (j > 1) out.print(' ');
                out.print(A[x - 1][y - 1]);
            }
            out.println();
        }
    }
    
    void swap(int[] a, int i, int j) {
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }
    
    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new WorkingRoutine().solve();
        out.close();
    }
    
    static FastScanner in;
    static PrintWriter out;
    
    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;
        
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
        
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
        
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}