#include <bits/stdc++.h>
using namespace std;
const int N = 15000;
int n, m, a[N];
bool b[N];
int st[N], tp;
inline void dfs(int pos) {
if (tp == m) {
for (int i = 1; i <= tp; ++i) cout << st[i] << ' ';
puts(""); return;
}
for (int i = st[tp] + 1; i <= n; ++i) {
if (b[i]) continue; b[i] = 1;
st[++tp] = i;
dfs(pos + 1);
st[tp--] = 0, b[i] = 0;
}
}
signed main() {
cin >> n >> m;
dfs(1);
return 0;
}