Processing math: 100%
Swap operation - MarisaOJ: Marisa Online Judge

Swap operation

Time limit: 1000 ms
Memory limit: 256 MB

You are given a 2D array A with n rows and m columns. There are q queries of either form:

  • 1ij: swap row i and row j.
  • 2ij: swap column i and column j.

Print array A after all q queries. It is guaranteed that all queries are valid.

Input

  • The first line contains 3 integers n,m,q.
  • The next n lines, each line contains m integers representing array A.
  • Next q lines, each line contains 3 integers 1ij or 2ij.

Output

  • n lines, each lines contains m integers represent array A after q queries.

Constraints

  • 1≤n,m,q≤100.
  • |Ai,j|≤100.

Example

Input:

2 2 2
1 2
3 4
1 1 2
2 1 2

Output:

4 3
2 1