Codeforces Round 367 (Div. 2)
E
Working routine
Codeforces
2500
原题
← D→
翻译中…

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 $*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.

翻译中…

样例

Input #1
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 #1
4 4 3 3
4 4 3 3
2 2 1 1
2 2 1 1
InputCopy OutputCopy
Input #2
4 2 1
1 1
1 1
2 2
2 2
1 1 4 1 1 2
Output #2
2 2
1 1
2 2
1 1
InputCopy OutputCopy
题目信息
题号
706E
时间限制
2.5 s
内存限制
256 MB
标签
数据结构
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。