#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
int N,M;
vector<int> choice;
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cin >> N >> M;
for(int i = 0; i < N; i++)
{
int a;
cin >> a;
choice.push_back(a);
}
for(int i = 0; i < M; i++)
{
next_permutation(choice.begin(), choice.end());
}
for(int i = 0; i < N; i++)
{
cout << choice[i] << " ";
}
return 0;
}
02-17
983
09-26
406
06-07