https://ac.nowcoder.com/acm/problem/16661
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
int n,m; cin>>n>>m;
int a[100005];
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;
}