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. How to count them? For example like this:

A=[] for i in range(n): A.append(list(map(int, input().split()))) # the list() method creates a list(array)   # from the set of data given in brackets

Or, without using complex nested function calls:

A=[] for i in range(n): row = input().split() # read a string with numbers, # split into elements by spaces (got array row) for i in range(len(row)): row[i] = int(row[i]) # each element of list row converted to a number A.append(row) # append array row to array A

Problem

Write a program that displays the transposed matrix.
Matrix transpose is a transformation that causes rows to become columns and – lines.

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