Under construction

Still being built. Things may change

Bae Chanwoo likes arrays

Time limit3sMemory limit512 MB

Summary
Given an N by M array, apply q queries that either set one cell or swap two rows, then print the final array.
Level

Easy3 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

Chanwoo learned about two-dimensional arrays in an introductory programming class today. He found it so interesting that he decided to apply operations to the two-dimensional array.

Two kinds of operations are given as queries.

  • 0 i j k: Change the value in column jj of row ii to kk.
  • 1 i j: Swap row ii and row jj.

A swap exchanges every element of row ii with the corresponding element of row jj.

After performing all qq queries, print the final array.

Input

The first line contains the number of rows NN, the number of columns MM, and the number of queries qq. (1≤N,M≤3000,1≤q≤106)(1 \le N, M \le 3000, 1 \le q \le 10^6)

From the second line onward, NN lines give the two-dimensional array with NN rows and MM columns. Each element of the array is an integer from 1 to 10 00010\,000.

The next qq lines contain the queries. A query has the form 0 i j k or 1 i j. If the first value is 0, perform the first operation. If it is 1, perform the second operation.

For the first operation, ii, jj, and kk satisfy 0≤i≤N−10 \le i \le N-1, 0≤j≤M−10 \le j \le M-1, and 1≤k≤10 0001 \le k \le 10\,000, where kk is an integer.

For the second operation, ii and jj satisfy 0≤i,j≤N−10 \le i, j \le N-1.

Output

Print the two-dimensional array after performing all qq queries.

Examples1

  1. Example 1

    Input
    4 3 4
    10 3 8
    2 10 4
    1 8 4
    1 4 2
    1 2 2
    0 1 0 9
    1 2 1
    1 3 0
    
    Expected output
    1 4 2
    1 8 4
    9 10 4
    10 3 8