import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] nm = br.readLine().split(" "); int n = Integer.parseInt(nm[0]); int m = Integer.parseInt(nm[1]); String[][] array = new String[n][m]; for (int i = 0; i < n; i++) { String[] arr = br.readLine().split(" "); for (int j = 0; j < m; j++) { array[i][j] = arr[j]; } } print(array, n, m); } public static void print(String[][] arr, int row, int column) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < column; i++) { for (int j = 0; j < row; j++) { sb.append(arr[j][i]).append(" "); } sb.append("\n"); } System.out.print(sb.toString()); } }