C. "Genshin Impact" or "Matrix"

    传统题 3000ms 256MiB

"Genshin Impact" or "Matrix"

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

The young man from Chongqing -- Xiao Yan is a student of Chongqing University of Posts and Telecommunications (CQUPT). He was so addicted to the game "Genshin Impact" during the course of Linear Algebra that he couldn't extricate himself.

There are T groups of data. For each group of data, you are provided with an n×m matrix. Your task is to output the transpose of this matrix.

The transpose of a matrix is an operation that flips a matrix over its diagonal. That is, for an n×mn \times m matrix AA with elements aija_{ij} (where ii represents the row number and jj represents the column number, 1≤i≤n1\leq i\leq n and 1≤j≤m1\leq j\leq m), its transpose, denoted as ATA^T, is an m×nm \times n matrix. In the transpose matrix ATA^T, the element in the ii-th row and jj-th column of the original matrix AA becomes the element in the jj-th row and ii-th column of ATA^T. In other words, if A=[aij]n×mA = [a_{ij}]_{n\times m}, then AT=[aji]m×nA^T=[a_{ji}]_{m\times n}. For example, if we have a matrix [123456]\begin{bmatrix}1&2\\3&4\\5&6\end{bmatrix}, its transpose is [135246]\begin{bmatrix}1&3&5\\2&4&6\end{bmatrix}, where the elements in the first row of the original matrix become the elements in the first column of the transposed matrix, and so on for other rows and columns.

Input Format

The first line contains an integer T(1≤T≤100)T (1≤T≤100), representing the number of groups of data.

For each group of data:

The first line contains two integers n and m (1≤n,m≤1000), representing the number of rows and columns of the matrix respectively.

Then n lines follow, each line contains m integers aij​ (1≤aij​≤1e9), representing the elements of the matrix.

Output Format

For each group of data, output the transpose of the input matrix. The transpose matrix should have m rows and n columns.

Each row of the output matrix should be printed on a separate line, and the elements in each row should be separated by a space.

Sample

输入 #1

2
3 2
1 2
3 4
5 6
2 3
1 2 3
4 5 6

输出 #1

1 3 5
2 4 6
1 4
2 5
3 6

重庆邮电大学第十九届ACM程序设计大赛(网络赛)

未参加
状态
已结束
规则
XCPC
题目
9
开始于
2025-3-15 0:00
结束于
2025-3-17 0:00
持续时间
48 小时
主持人
参赛人数
3