import java.util.ArrayDeque;
import java.util.Deque;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static public void main(String[] args) throws IOException {
Solution ts = new Solution();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] fl = br.readLine().split(" ");
int N = Integer.parseInt(fl[0]);
int M = Integer.parseInt(fl[1]);
ts.solution(N, M);
}
}
class Solution {
int maxNum;
int numCountLimit;
public void solution(int N, int M) {
maxNum = N;
numCountLimit = M;
Deque<Integer> queue = new ArrayDeque<>();
dfs(queue, 1);
}
private void dfs(Deque<Integer> queue, int startNum) {
if (queue.size() == numCountLimit) {
StringBuilder sb = new StringBuilder();
for (Integer integer : queue) {
sb.append(integer).append(" ");
}
System.out.println(sb);
return;
}
for (int i = startNum; i <= maxNum; i++) {
queue.offerLast(i);
dfs(queue, i);
queue.pollLast();
}
}
}