import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), i = 0;
        while (sc.hasNext()){
            if(i++ < m) System.out.printf("%d ", sc.nextInt());
            else{
                i = 1;
                System.out.printf("\n%d ", sc.nextInt());
            }
        }
    }
}