import java.util.Scanner;
public class p矩阵的转置 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner =new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int[][] arr = new int[n][m];
//赋值
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
arr[i][j] = scanner.nextInt();
}
}
System.out.println();
//转置输出
int[][] arrs = new int[n][m];
for(int i=0;i<n;i++) { //行转列
for(int j=0;j<n;j++) {
arrs[i][j] = arr[j][i];
System.out.print(arrs[i][j]+" ");
}
System.out.println();
}
}
}