Problem

2 /12


Filling the matrix from the keyboard

Theory Click to read/hide

Filling a matrix with values ​​from the keyboard

Let the program receive a two-dimensional array as input, in the form of n lines, each of which contains m numbers separated by spaces. You can save such data to a two-dimensional array like this:

read(n, m); set length(a, n); for i:= 0 to n - 1 do begin     setlength(a[i], m);     for j := 0 to m - 1 do read(a[i][j]); end;

Problem

Write a program that displays the transposed matrix. Matrix transposition is a  transformation where rows become columns and – lines. The matrix itself does not need to be changed. It is enough to display it in the desired form.

Input
The first line contains the dimensions of the matrix separated by a space: the number of rows N and the number of columns M ( 1 <= N,  M <= 100 ). The following N lines contain matrix rows, each – by M natural numbers separated by spaces.

Imprint
The program should output a matrix that would result as a result of transposition by rows.

Examples
# Input Output
1 4 5
1 2 3 4 5
6 7 8 9 3
5 4 3 2 1
7 9 8 7 6
1 6 5 7
2 7 4 9
3 8 3 8
4 9 2 7
5 3 1 6