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:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package spoj;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author TuAnh
 */
public class E706 {

    private static final int MODE = 2;

    static class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            if (MODE == 1) {
                FileInputStream f;
                try {
                    f = new FileInputStream("e:\\spoj\\input.txt");
                    br = new BufferedReader(new InputStreamReader(f));
                } catch (FileNotFoundException ex) {
                    br = new BufferedReader(new InputStreamReader(System.in));
                }
            } else {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
            st = new StringTokenizer("");
        }

        String next() throws Exception {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        int nextInt() throws Exception {
            return Integer.parseInt(next());
        }

        public long nextLong() throws Exception {
            return Long.parseLong(next());
        }

        public String nextLine() throws Exception {
            return br.readLine();
        }

        public double nextDouble() throws Exception {
            return Double.parseDouble(next());
        }

        public boolean ready() throws Exception {
            return br.ready();
        }
    }
    private static FastScanner inp = new FastScanner();
    private static PrintWriter pw = new PrintWriter(System.out);

    private static class P {

        int v;
        P top, down, right, left;

        public P(int v) {
            this.v = v;
        }
    }

    private static P a[][] = new P[1003][1003];
    private static int n, m, q;
    private static int x1, x2, y1, y2, w, h;

    private static P find(int x, int y) {
        P s = a[x][0];
        while (y-- > 0) {
            s = s.right;
        }
        return s;
    }

    public static void main(String agrs[]) throws Exception {
        n = inp.nextInt();
        m = inp.nextInt();
        q = inp.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = new P(inp.nextInt());
            }
        }
        //Init
        //border
        for (int i = 1; i <= n; i++) {
            a[i][0] = new P(0);
            a[i][0].right = a[i][1];
            a[i][m + 1] = new P(0);
            a[i][m + 1].left = a[i][m];
        }
        for (int i = 1; i <= m; i++) {
            a[0][i] = new P(0);
            a[0][i].down = a[1][i];
            a[n + 1][i] = new P(0);
            a[n + 1][i].top = a[n][i];
        }
        ///////
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j].top = a[i - 1][j];
                a[i][j].down = a[i + 1][j];
                a[i][j].left = a[i][j - 1];
                a[i][j].right = a[i][j + 1];
            }
        }
        while (q-- > 0) {
            x1 = inp.nextInt();
            y1 = inp.nextInt();
            x2 = inp.nextInt();
            y2 = inp.nextInt();
            h = inp.nextInt();
            w = inp.nextInt();
            /////////////
            P source = find(x1, y1), des = find(x2, y2);
            // Swap top
            for (int i = 1; i <= w; i++) {
                P tmp1 = source.top;
                P tmp2 = des.top;
                source.top = tmp2;
                des.top = tmp1;
                tmp1.down = des;
                tmp2.down = source;
                if (i != w) {
                    source = source.right;
                    des = des.right;
                }
            }
            // swap right
            for (int i = 1; i <= h; i++) {
                P tmp1 = source.right;
                P tmp2 = des.right;
                source.right = tmp2;
                des.right = tmp1;
                tmp1.left = des;
                tmp2.left = source;
                if (i != h) {
                    source = source.down;
                    des = des.down;
                }
            }
            /// swap bottom
            for (int i = 1; i <= w; i++) {
                P tmp1 = source.down;
                P tmp2 = des.down;
                source.down = tmp2;
                des.down = tmp1;
                tmp1.top = des;
                tmp2.top = source;
                if (i != w) {
                    source = source.left;
                    des = des.left;
                }
            }
            // swap left
            for (int i = 1; i <= h; i++) {
                P tmp1 = source.left;
                P tmp2 = des.left;
                source.left = tmp2;
                des.left = tmp1;
                tmp1.right = des;
                tmp2.right = source;
                if (i != h) {
                    source = source.top;
                    des = des.top;
                }
            }
        }
        // xuat
        for (int i = 1; i <= n; i++) {
            P s = a[i][0];
            for (int j = 1; j <= m; j++) {
                s = s.right;
                pw.print(s.v);
                pw.append(' ');
            }
            pw.println();
        }
        pw.flush();
        pw.close();
    }
}