#include <iostream>
#include <set>
using namespace std;
struct node{
int val,cnt;
bool operator<(const node&a)const{
return(cnt!=a.cnt)?cnt>a.cnt:val<a.val;
}
};
int book[50001];
int main() {
int n,k,num;
cin>>n>>k;
set<node>s;
for(int i=0;i<n;i++){
cin>>num;
if(i!=0){
printf("%d:",num);
int tempCnt=0;
for(auto it=s.begin();tempCnt<k&&it!=s.end();it++){
printf(" %d",it->val);
tempCnt++;
}
printf("\n");
}
auto it=s.find(node{num,book[num]});
if(it!=s.end()) s.erase(it);
book[num]++;
s.insert(node{num,book[num]});
}
return 0;
}
|