706_E. Working routine_5271
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
import java.io.*;
import java.util.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "";
            if (filename.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    class Graph {
        int[][] graph;
        List<Integer>[] temp;
        int n;

        Graph(int n) {
            this.n = n;
            graph = new int[n][];
            temp = createGraphList(n);
        }

        void add(int x, int y) {
            temp[x].add(y);
            temp[y].add(x);
        }

        void addDir(int x, int y) {
            temp[x].add(y);
        }

        void build() {
            for (int i = 0; i < n; i++) {
                graph[i] = new int[temp[i].size()];
                for (int j = 0; j < temp[i].size(); j++) graph[i][j] = temp[i].get(j);
            }
        }

        void buildWithUniq() {
            for (int i = 0; i < n; i++) {
                HashSet<Integer> uniqSet = new HashSet<>();
                uniqSet.addAll(temp[i]);
                graph[i] = new int[uniqSet.size()];
                int index = 0;
                for (int x : uniqSet) {
                    graph[i][index++] = x;
                }
            }
        }
    }

    public static void main(String[] args) {
        new Template().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    class Node {
        Node left;
        Node right;
        Node up;
        Node down;
        int value;

        Node(int x) {
            value = x;
        }
    }

    Node root;

    Node find(int i, int j) {
        Node res = root;
        while (i > 0) {
            res = res.down;
            i--;
        }
        while (j > 0) {
            res = res.right;
            j--;
        }
        return res;
    }

    void swapUp(Node x, Node y) {
        if (x.up != null) {
            x.up.down = y;
        }
        if (y.up != null) {
            y.up.down = x;
        }
        Node t = x.up;
        x.up = y.up;
        y.up = t;
    }

    void swapDown(Node x, Node y) {
        if (x.down != null) {
            x.down.up = y;
        }
        if (y.down != null) {
            y.down.up = x;
        }
        Node t = x.down;
        x.down = y.down;
        y.down = t;
    }

    void swapLeft(Node x, Node y) {
        if (x.left != null) {
            x.left.right = y;
        }
        if (y.left != null) {
            y.left.right = x;
        }
        Node t = x.left;
        x.left = y.left;
        y.left = t;
    }

    void swapRight(Node x, Node y) {
        if (x.right != null) {
            x.right.left = y;
        }
        if (y.right != null) {
            y.right.left = x;
        }
        Node t = x.right;
        x.right = y.right;
        y.right = t;
    }

    private void solve() {
        int n = readInt();
        int m = readInt();
        int q = readInt();
        Node[][] nodes = new Node[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                nodes[i][j] = new Node(readInt());
            }
        }
        root = nodes[0][0];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i - 1 >= 0) {
                    nodes[i][j].up = nodes[i - 1][j];
                }
                if (i + 1 < n) {
                    nodes[i][j].down = nodes[i + 1][j];
                }
                if (j - 1 >= 0) {
                    nodes[i][j].left = nodes[i][j - 1];
                }
                if (j + 1 < m) {
                    nodes[i][j].right = nodes[i][j + 1];
                }
            }
        }

        while (q-- > 0) {
            int a = readInt();
            int b = readInt();
            int c = readInt();
            int d = readInt();
            int h = readInt();
            int w = readInt();

            Node nodeA = find(a - 1, b - 1);
            Node nodeB = find(c - 1, d - 1);
            if (nodeA == root) {
                root = nodeB;
            } else if (nodeB == root) {
                root = nodeA;
            }

            for (int i = 0; i < w; i++) {
                swapUp(nodeA, nodeB);
                if (i != w - 1) {
                    nodeA = nodeA.right;
                    nodeB = nodeB.right;
                }
            }

            for (int i = 0; i < h; i++) {
                swapRight(nodeA, nodeB);
                if (i != h - 1) {
                    nodeA = nodeA.down;
                    nodeB = nodeB.down;
                }
            }

            for (int i = 0; i < w; i++) {
                swapDown(nodeA, nodeB);
                if (i != w - 1) {
                    nodeA = nodeA.left;
                    nodeB = nodeB.left;
                }
            }

            for (int i = 0; i < h; i++) {
                swapLeft(nodeA, nodeB);
                if (i != h - 1) {
                    nodeA = nodeA.up;
                    nodeB = nodeB.up;
                }
            }
        }

        Node x = root;
        for (int i = 0; i < n; i++) {
            Node next = x.down;
            for (int j = 0; j < m; j++) {
                out.print(x.value + " ");
                x = x.right;
            }
            out.println();
            x = next;
        }


    }


}