#include<bits/stdc++.h>
using namespace std;
int n, k;
int a[10001];
bool b[10001];
void print()
{
for(int i = 1; i <= n; i ++)
cout << a[i] << " ";
cout << endl;
}
void dfs(int x)
{
for(int i = 1; i <= k; i ++)
{
if(!b[i])
{
a[x] = i;
b[i] = 1;
if(x == n)
print();
else
dfs(x + 1);
b[i] = 0;
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> k;
dfs(1);
return 0;
}
不能输出重复的数字