import java.util.Scanner;
public class BOJ_15652 {
static int[] arr = new int[8];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
go(0, n, m);
}
private static void go(int index, int n, int m) {
if (index == m) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < m; i++) {
sb.append(arr[i]);
sb.append(" ");
}
sb.append("\n");
System.out.print(sb.toString());
return;
}
for (int i = 1; i <= n; i++) {
if(index > 0){
if(arr[index-1] > i)
continue;
}
arr[index] = i;
go(index + 1, n, m);
}
}
}