include [HTML_REMOVED]
using namespace std;
int N = 1e5;
int main(){
int n,m,a[N];
cin >>n >>m;
for(int i = 0;i < n; i++){
cin >> a[i];
}
while (m–){
int t1 = n - 1;
while(a[t1] < a[t1-1]) t1–;
t1–;
int t2 = n - 1;
while (a[t2] < a[t1]) t2– ;
swap(a[t1],a[t2]);//交换
reverse(a + t1 + 1,a + n);//翻转
}
int i = 0 ;
while(i < n){
cout<< a[i] <<" ";
i++;
}
cout<<endl;
return 0;
}