Matrix

Accepts: 214
Submissions: 1115
Time Limit: 3000/1500 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
Problem Description
There is a matrix $M$ that has $n$ rows and $m$ columns $(1 \leq n \leq 1000 ,1 \leq m \leq 1000 )$.Then we perform $q (1 \leq q \leq 100,000)$ operations: 1 x y: Swap row x and row y $(1 \leq x,y \leq n)$; 2 x y: Swap column x and column y $(1 \leq x,y \leq m)$; 3 x y: Add y to all elements in row x $(1 \leq x \leq n,1 \leq y \leq 10,000)$; 4 x y: Add y to all elements in column x $(1 \leq x \leq m,1 \leq y \leq 10,000)$;
Input
There are multiple test cases. The first line of input contains an integer $T (1\leq T\leq 20)$ indicating the number of test cases. For each test case: The first line contains three integers $n$, $m$ and $q$. The following $n$ lines describe the matrix M.$(1 \leq M_{i,j} \leq 10,000)$ for all $(1 \leq i \leq n,1 \leq j \leq m)$. The following $q$ lines contains three integers $a(1 \leq a \leq 4)$, $x$ and $y$.
Output
For each test case, output the matrix $M$ after all $q$ operations.
Sample Input
2
3 4 2
1 2 3 4
2 3 4 5
3 4 5 6
1 1 2
3 1 10
2 2 2
1 10
10 1
1 1 2
2 1 2
Sample Output
12 13 14 15
1 2 3 4
3 4 5 6
1 10
10 1
Hint
Recommand to use scanf and printf