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.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

import com.sun.org.apache.xml.internal.serialize.OutputFormat.DTD;

/*
 public class _706E {

 }

 */

public class _706E {

  class node {
    int val;

    node right;
    node down;

    public node(int val) {
      super();
      this.val = val;
    }


  }

  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper inputHelper = new InputHelper(inputStream);

    PrintStream out = System.out;

    // actual solution
    int n = inputHelper.readInteger();
    int m = inputHelper.readInteger();

    int q = inputHelper.readInteger();

    node[] rootr = new node[n];
    node[] rootd = new node[m];

    for (int i = 0; i < n; i++) {
      node prev = rootr[i] = new node(-1);

      for (int j = 0; j < m; j++) {
        node cn = new node(inputHelper.readInteger());

        prev.right = cn;

        prev = cn;
      }
    }

    for (int i = 0; i < n - 1; i++) {

      node cur = rootr[i];
      node next = rootr[i + 1];

      int j = 0;
      while (cur != null) {
        cur.down = next;

        cur = cur.right;
        next = next.right;

        if (i == 0 && cur != null) {
          rootd[j] = new node(-1);
          rootd[j].down = cur;

          if (j > 0) {
            rootd[j - 1].right = rootd[j];
          }
          j++;
        }
      }
    }

    while (q-- > 0) {
      int a = inputHelper.readInteger() - 1;
      int b = inputHelper.readInteger() - 1;
      int c = inputHelper.readInteger() - 1;
      int d = inputHelper.readInteger() - 1;
      int h = inputHelper.readInteger();
      int w = inputHelper.readInteger();

      node starta = rootr[a];
      node startc = rootr[c];
      node startb = rootd[b];
      node startd = rootd[d];

      for (int i = 0; i < b; i++) {
        starta = starta.right;
      }

      for (int i = 0; i < d; i++) {
        startc = startc.right;
      }

      for (int i = 0; i < a; i++) {
        startb = startb.down;
      }

      for (int i = 0; i < c; i++) {
        startd = startd.down;
      }

      node starta2 = starta;
      node startc2 = startc;
      node startb2 = startb;
      node startd2 = startd;

      for (int i = 0; i < w; i++) {
        starta2 = starta2.right;
        startc2 = startc2.right;
      }

      for (int i = 0; i < h; i++) {
        startb2 = startb2.down;
        startd2 = startd2.down;
      }

      for (int i = 0; i < h; i++) {
        node tmp = starta.right;
        starta.right = startc.right;
        startc.right = tmp;

        starta = starta.down;
        startc = startc.down;
      }

      for (int i = 0; i < w; i++) {
        node tmp = startb.down;
        startb.down = startd.down;
        startd.down = tmp;

        startb = startb.right;
        startd = startd.right;
      }

      // ///
      for (int i = 0; i < h; i++) {
        node tmp = starta2.right;
        starta2.right = startc2.right;
        startc2.right = tmp;

        starta2 = starta2.down;
        startc2 = startc2.down;
      }

      for (int i = 0; i < w; i++) {
        node tmp = startb2.down;
        startb2.down = startd2.down;
        startd2.down = tmp;

        startb2 = startb2.right;
        startd2 = startd2.right;
      }
    }

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < n; i++) {
      node cur = rootr[i].right;
      for (int j = 0; j < m; j++) {
        sb.append(cur.val);
        sb.append(" ");
        cur = cur.right;
      }
      sb.append("\n");
    }

    System.out.println(sb.toString());
    // end here
  }

  public static void main(String[] args) throws FileNotFoundException {
    (new _706E()).solve();
  }

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}