#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<set>
#include<queue>
#include<unordered_set>
using namespace std;
using namespace std;
int book[50001];
struct node {
int value, cnt;
node(int a, int b) :value(a), cnt(b) {}
bool friend operator < (node a,node b)
{
if (a.cnt != b.cnt)
return a.cnt > b.cnt;
else
return a.value < b.value;
}
};
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->value);
tempCnt++;
}
printf("
");
}
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;
}