11137 - Matrix Transpose   

Description

A matrix A of dimension (N,M) has N*M elements in the format of N rows(橫列) and M columns(直行), and thus each element has a pair of index (i, j), where i is less than N, j is less than M, and both are greater or equal to 0.  For example, a matrix A of dimension (2, 3) may look like this:

[  1 3 5  ]
[  2 4 6  ]

where the element A(0,1) is 3 and A(1, 0) is 2.

In linear algebra, a transpose of a matrix A, which is AT, is to reflect the A over its main diagonal(主對角線). For each element A(i,j), the new location of the element in the AT is (j,i).

In this problem, a matrix A is given, and you are asked to output AT, which is the transpose of A.

Input

The input consists of 2 parts, which present the marix A:

  1. The dimentsion of the matrix: two positive integers N and M in one line, and both are not greater than 30.
  2. The matrix itself: N lines and each line contains M decimal integers that have one 1 digit (0-9). All integers in the a line are seperated by a space.

Output

Output is the matrix AT, which should have M rows. All elements in a row should be seperated by a space, and make sure there is no trailing spaces at the end of each line.

Sample Input  Download

Sample Output  Download

Tags

2016F_Lee_Lab3



Discuss