import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
class Main {
static int N, M;
static int[] arr;
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());
arr = new int[M];
dfs(1, 0);
System.out.print(sb);
}
public static void dfs(int at, int depth) {
if (depth == M) {
for (int value : arr) {
sb.append(value).append(" ");
}
sb.append("\n");
return;
}
for (int i = at; i <= N; i++) {
arr[depth] = i;
dfs(i + 1, depth + 1);
}
}
}```
![](https://velog.velcdn.com/images%2Fcheal3%2Fpost%2Ff7354ff3-a530-471d-a4ab-b93c9daa82df%2Fimage.png)