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 A {
    public static void main(String[] args)throws Throwable {
        MyScanner sc=new MyScanner();
        PrintWriter pw=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();
        int q=sc.nextInt();
        node [][] a=new node [n+2][m+2];
        for(int i=0;i<n+2;i++)
            for(int j=0;j<m+2;j++)
                a[i][j]=new node(0);
        for(int i=0;i<=n+1;i++)
            for(int j=0;j<=m+1;j++){
                if(i>0 && i<=n && j>0 && j<=m)
                    a[i][j].val=sc.nextInt();
                if(j>0)
                    a[i][j].l=a[i][j-1];
                if(j<m+1)
                    a[i][j].r=a[i][j+1];
                if(i>0)
                    a[i][j].u=a[i-1][j];
                if(i<n+1)
                    a[i][j].d=a[i+1][j];
            }
        while(q-->0){
            int x1=sc.nextInt();
            int y1=sc.nextInt();
            int x2=sc.nextInt();
            int y2=sc.nextInt();
            node n1=a[0][0];
            while(x1-->0)
                n1=n1.d;
            while(y1-->0)
                n1=n1.r;
            node n2=a[0][0];
            while(x2-->0)
                n2=n2.d;
            while(y2-->0)
                n2=n2.r;
            int h=sc.nextInt()-1;
            int w=sc.nextInt()-1;

            swapU(n1,n2);
            for(int i=0;i<w;i++){
                n1=n1.r;
                n2=n2.r;
                swapU(n1,n2);
            }
            swapR(n1,n2);
            for(int i=0;i<h;i++){
                n1=n1.d;
                n2=n2.d;
                swapR(n1,n2);
            }
            swapD(n1,n2);
            for(int i=0;i<w;i++){
                n1=n1.l;
                n2=n2.l;
                swapD(n1,n2);
            }
            swapL(n1,n2);
            for(int i=0;i<h;i++){
                n1=n1.u;
                n2=n2.u;
                swapL(n1,n2);
            }
        }
        node start=a[0][0].d;
        for(int i=0;i<n;i++){
            node cur=start;
            for(int j=0;j<m;j++){
                cur=cur.r;
                pw.print(cur.val+" ");
            }
            pw.println();
            start=start.d;
        }


        pw.flush();
        pw.close();
    }

    static class node{
        int val;
        node r,l,u,d;
        node(int val){
            this.val=val;
        }
    }

    static void swapR(node a,node b){
        node r1=a.r;
        node r2=b.r;
        a.r=r2;
        b.r=r1;
        r1.l=b;
        r2.l=a;
    }

    static void swapL(node a,node b){
        node l1=a.l;
        node l2=b.l;
        a.l=l2;
        b.l=l1;
        l1.r=b;
        l2.r=a;
    }

    static void swapU(node a,node b){
        node u1=a.u;
        node u2=b.u;
        a.u=u2;
        b.u=u1;
        u1.d=b;
        u2.d=a;
    }

    static void swapD(node a,node b){
        node d1=a.d;
        node d2=b.d;
        a.d=d2;
        b.d=d1;
        d1.u=b;
        d2.u=a;
    }


    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {while (st == null || !st.hasMoreElements()) {
            try {st = new StringTokenizer(br.readLine());}
            catch (IOException e) {e.printStackTrace();}}
            return st.nextToken();}
        int nextInt() {return Integer.parseInt(next());}
        long nextLong() {return Long.parseLong(next());}
        double nextDouble() {return Double.parseDouble(next());}
        String nextLine(){String str = "";
            try {str = br.readLine();}
            catch (IOException e) {e.printStackTrace();}
            return str;}
    }
}