
#include <iostream>
using namespace std;
#define MAX 9
int arr[MAX];
bool visit[MAX] = { false };
int N{ 0 }, M{ 0 };
void NandM(int depth) {
if (depth == M) {
for (int i = 0; i < depth; i++) cout << arr[i] << " ";
cout << "\n";
}
else {
for (int i = 1; i <= N; i++) {
if (arr[depth - 1] <= i) {
arr[depth] = i;
NandM(depth + 1);
}
}
}
}
int main() {
cin >> N >> M;
NandM(0);
}


