package challenges_CB_2;
import java.util.Scanner;
public class RotateAntiClock {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[][] a = new int[n][m];
int[][] output = new int[n][m];
for(int i=0;i<n;i++) {
for(int j =0;j<m;j++) {
a[i][j] = sc.nextInt();
}
}
AnitClockRotate(a);
}
public static void AnitClockRotate(int[][] a) {
int[][] output = new int[a.length][a[0].length];
for(int i = a[0].length-1;i>=0;i--) {
for(int j =0;j<=a.length-1;j++) {
System.out.print(a[j][i]+" ");
}
System.out.println();
}
}
}