#C12755. Transpose a Matrix

    ID: 42217 Type: Default 1000ms 256MiB

Transpose a Matrix

Transpose a Matrix

Given a matrix with dimensions \(n \times m\), your task is to compute its transpose. The transpose of a matrix is another matrix whose rows are the columns of the original. More formally, if \(A\) is an \(n \times m\) matrix, then its transpose \(A^T\) is an \(m \times n\) matrix defined by \(A^T_{ij} = A_{ji}\) for all valid \(i\) and \(j\).

Your solution must read from standard input and write to standard output.

inputFormat

The first line of input contains two integers \(n\) and \(m\) separated by a space, representing the number of rows and columns of the matrix respectively. The next \(n\) lines each contain \(m\) integers separated by spaces, representing the matrix elements.

outputFormat

Output the transposed matrix in \(m\) lines. Each line should contain \(n\) integers separated by a single space.

## sample
2 2
1 2
3 4
1 3

2 4

</p>