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

public class ProblemE {
  
  public static void main(String[] args) throws IOException {
    init();
    new ProblemE().run();
    out.flush();
    out.close();
  }
  
  static void init() throws IOException {
    in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    out = new PrintWriter(new OutputStreamWriter(System.out));
    in.ordinaryChars(0, 65535);
    in.wordChars(0, 65535);
    in.whitespaceChars(' ', ' ');
    in.whitespaceChars('\n', '\n');
    in.whitespaceChars('\r', '\r');
  }
  
  // класс для пар
  class Pair<L, R> {
    private final L X;
    private final R Y;
    
    public Pair(L X, R Y) {
      this.X = X;
      this.Y = Y;
    }
    
    public L getX() {
      return X;
    }
    
    public R getY() {
      return Y;
    }
    
    @Override
    public int hashCode() {
      return X.hashCode() ^ Y.hashCode();
    }
    
    @Override
    public boolean equals(Object o) {
      if (!(o instanceof Pair)) return false;
      Pair pairo = (Pair) o;
      return X.equals(pairo.getX()) && Y.equals(pairo.getY());
    }
  }
  
  static final long INFL = 200000000000000000L;
  static final int INF = 2000000000;
  static final boolean DEBUG = true;
  
  static StreamTokenizer in;
  static PrintWriter out;
  
  static void print(String s) {
    print(s, 0);
  }
  
  static void print(String s, int debug) {
    if (debug == 0 || DEBUG) {
      out.print(s);
    }
  }
  
  static void println(String s) {
    println(s, 0);
  }
  
  static void println(String s, int debug) {
    if (debug == 0 || DEBUG) {
      out.println(s);
    }
  }
  
  static void printArray(int[] arr) {
    println(Arrays.toString(arr));
  }
  
  static void printArray(char[] arr) {
    println(Arrays.toString(arr));
  }
  
  static void printArray(String[] arr) {
    println(Arrays.toString(arr));
  }
  
  static void sort(int[] a) {
    Random rnd = new Random();
    for (int i = a.length - 1; i > 0; i--) {
      int index = rnd.nextInt(i);
      a[i] ^= a[index];
      a[index] ^= a[i];
      a[i] ^= a[index];
    }
    Arrays.sort(a);
  }
  
  static char[] inChars;
  static int inCharsInd;
  
  static String next() throws IOException {
    in.nextToken();
    return in.sval;
  }
  
  static char nextChar() throws IOException {
    while (inChars == null || inCharsInd >= inChars.length) {
      inChars = next().toCharArray();
      inCharsInd = 0;
    }
    return inChars[inCharsInd++];
  }
  
  static int nextInt() throws IOException {
    return Integer.valueOf(next());
  }
  
  static double nextDouble() throws IOException {
    return Double.valueOf(next());
  }
  
  static long nextLong() throws IOException {
    return Long.valueOf(next());
  }
  
  private void run() throws IOException {
    solve();
  }
  
  int K, L, M, N, P;


  class Cell{
    Cell up;
    Cell down;
    Cell left;
    Cell right;

    void swapUp(Cell c){
      Cell up = c.up;
      c.up = this.up;
      this.up = up;
      if (this.up != null) {
        this.up.down = this;
      }
      if (c.up != null) {
        c.up.down = c;
      }
    }

    void swapDown(Cell c){
      Cell down = c.down;
      c.down = this.down;
      this.down = down;

      if (this.down != null) {
        this.down.up = this;
      }
      if (c.down != null) {
        c.down.up = c;
      }
    }

    void swapLeft(Cell c){
      Cell left = c.left;
      c.left = this.left;
      this.left = left;

      if (this.left != null) {
        this.left.right = this;
      }
      if (c.left != null) {
        c.left.right = c;
      }
    }

    void swapRight(Cell c){
      Cell right = c.right;
      c.right = this.right;
      this.right = right;

      if (this.right != null) {
        this.right.left = this;
      }
      if (c.right != null) {
        c.right.left = c;
      }
    }

    long value;

    public Cell(long value) {
      this.value = value;
    }
  }

  Cell begin;

  private void solve() throws IOException {
    N = nextInt();
    M = nextInt();
    int Q = nextInt();

    Cell[][] cells = new Cell[N][M];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        cells[i][j] = new Cell(nextInt());
        if (i > 0){
          cells[i][j].up = cells[i-1][j];
          cells[i-1][j].down = cells[i][j];
        }
        if (j > 0) {
          cells[i][j].left = cells[i][j - 1];
          cells[i][j-1].right = cells[i][j];
        }
      }
    }
    begin = cells[0][0];

    for (int i = 0; i < Q; i++) {
      work(nextInt()-1, nextInt()-1, nextInt()-1, nextInt()-1, nextInt(), nextInt());
    }

    Cell curLine = begin;
    Cell curColumn = begin;
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        sb.append(curColumn.value);
        sb.append(' ');
        curColumn = curColumn.right;
      }
      sb.append('\n');
      curLine = curLine.down;
      curColumn = curLine;
    }
    out.println(sb.toString());
  }
  
  private void work(int a, int b, int c, int d, int h, int w) {
    Cell first = begin;
    for (int i = 0; i < a; i++) {
      first = first.down;
    }
    for (int i = 0; i < b; i++) {
      first = first.right;
    }
    Cell second = begin;
    for (int i = 0; i < c; i++) {
      second = second.down;
    }
    for (int i = 0; i < d; i++) {
      second = second.right;
    }

    for (int i = 0; i < w-1; i++) {
      first.swapUp(second);
      first = first.right;
      second = second.right;
    }
    first.swapUp(second);

    for (int i = 0; i < h-1; i++) {
      first.swapRight(second);
      first = first.down;
      second = second.down;
    }
    first.swapRight(second);

    for (int i = 0; i < w-1; i++) {
      first.swapDown(second);
      first = first.left;
      second = second.left;
    }
    first.swapDown(second);

    for (int i = 0; i < h-1; i++) {
      first.swapLeft(second);
      first = first.up;
      second = second.up;
    }
    first.swapLeft(second);

    if (a == 0 && b == 0){
      begin = second;
    }
    if (c == 0 && d == 0){
      begin = first;
    }
  }
  
}