Java
import java.util.Scanner;
public class Main {
static int []way = new int[30];
static int n,m;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
dfs(1,1);
}
public static void dfs(int num,int start){
if(num>m){
for(int i=1; i<=m; i++){
System.out.print(way[i] + " ");
}
System.out.println();
return;
}
for(int i=start; i<=n; i++){
way[num]=i;
dfs(num+1, i+1);
way[num]=0;
}
}
}