atcoder#ABC237B. [ABC237B] Matrix Transposition

[ABC237B] Matrix Transposition

Score : 200200 points

Problem Statement

You are given an HH-by-WW matrix AA. The element at the ii-th row from the top and jj-th column from the left of AA is Ai,jA_{i,j}.

Let BB be a WW-by-HH matrix whose element at the ii-th row from the top and jj-th column from the left equals Aj,iA_{j, i}. That is, BB is the transpose of AA.

Print BB.

Constraints

  • 1H,W1051\leq H,W \leq 10^5
  • H×W105H \times W \leq 10^5
  • 1Ai,j1091 \leq A_{i,j} \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

HH WW

A1,1A_{1,1} A1,2A_{1,2} \ldots A1,WA_{1,W}

A2,1A_{2,1} A2,2A_{2,2} \ldots A2,WA_{2,W}

\vdots

AH,1A_{H,1} AH,2A_{H,2} \ldots AH,WA_{H,W}

Output

Print BB in the following format:

B1,1B_{1,1} B1,2B_{1,2} \ldots B1,HB_{1,H}

B2,1B_{2,1} B2,2B_{2,2} \ldots B2,HB_{2,H}

\vdots

BW,1B_{W,1} BW,2B_{W,2} \ldots BW,HB_{W,H}

4 3
1 2 3
4 5 6
7 8 9
10 11 12
1 4 7 10
2 5 8 11
3 6 9 12

For example, we have A2,1=4A_{2,1}=4, so the element at the 11-st row from the top and 22-nd column from the left of the transpose BB is 44.

2 2
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000