Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E. Working routine

time limit per test

2.5 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputVasiliy 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 *a*_{i}, *b*_{i}, *c*_{i}, *d*_{i}, *h*_{i}, *w*_{i}, where *a*_{i} is the index of the row where the top-left corner of the first rectangle is located, *b*_{i} is the index of its column, *c*_{i} is the index of the row of the top-left corner of the second rectangle, *d*_{i} is the index of its column, *h*_{i} is the height of the rectangle and *w*_{i} 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 *v*_{i, j} (1 ≤ *v*_{i, j} ≤ 10^{9}) each — initial values of the cells of the matrix.

Each of the following *q* lines contains six integers *a*_{i}, *b*_{i}, *c*_{i}, *d*_{i}, *h*_{i}, *w*_{i} (1 ≤ *a*_{i}, *c*_{i}, *h*_{i} ≤ *n*, 1 ≤ *b*_{i}, *d*_{i}, *w*_{i} ≤ *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

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/30/2017 06:05:50 (c2).

Desktop version, switch to mobile version.
User lists

Name |
---|