import java.util.Scanner;
public class BOJ_15650 {
static boolean[] check = new boolean[9];
static int[] arr = new int[9];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
go(0, 1, n, m);
}
private static void go(int index, int start, int n, int m) {
if (index == m) {
for (int i = 0; i < index; i++) {
System.out.print(arr[i]);
if (i < m)
System.out.print(" ");
}
System.out.println();
return;
}
for (int i = start; i <= n; i++) {
if (check[i])
continue;
check[i] = true;
arr[index] = i;
go(index + 1, i + 1, n, m);
check[i] = false;
}
}
}