Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()){
int a=scanner.nextInt(); //行
int b=scanner.nextInt(); //列
int[][] ary = new int[a][b];
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
ary[i][j]=scanner.nextInt();
}
}
for(int i=0;i<b;i++){
for(int j=0;j<a;j++){
System.out.print(ary[j][i] + " ");
}
System.out.println();
}
}