全排列
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 10010;
int n,m;
int a[N];
int main()
{
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i];
while(m--)
next_permutation(a,a+n);
for(int i=0;i<n;i++)cout<<a[i]<<" ";
return 0;
}