import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] arr = new int[n * m + 1];
        for (int i = 1; i < arr.length; i++) {
            arr[i] = scan.nextInt();
        }
        for (int i = 1; i < arr.length; i++) {
            if (i % m == 0) {
                System.out.println(arr[i]);
            } else {
                System.out.print(arr[i] + " ");
            }
        }
    }
}