#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
unordered_map<int, int> freq;
for (int i = 0; i < n; ++i) {
int id;
cin >> id;
freq[id]++;
}
vector<pair<int, int>> result;
for (auto &item : freq) {
if (item.second >= m) {
result.push_back({item.first, item.second});
}
}
sort(result.begin(), result.end());
for (auto &item : result) {
cout << item.first << " " << item.second << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIGludCBuLCBtOwogICAgY2luID4+IG4gPj4gbTsKICAgIAogICAgdW5vcmRlcmVkX21hcDxpbnQsIGludD4gZnJlcTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICAgICAgaW50IGlkOwogICAgICAgIGNpbiA+PiBpZDsKICAgICAgICBmcmVxW2lkXSsrOwogICAgfQogICAgCiAgICB2ZWN0b3I8cGFpcjxpbnQsIGludD4+IHJlc3VsdDsKICAgIGZvciAoYXV0byAmaXRlbSA6IGZyZXEpIHsKICAgICAgICBpZiAoaXRlbS5zZWNvbmQgPj0gbSkgewogICAgICAgICAgICByZXN1bHQucHVzaF9iYWNrKHtpdGVtLmZpcnN0LCBpdGVtLnNlY29uZH0pOwogICAgICAgIH0KICAgIH0KICAgIAogICAgc29ydChyZXN1bHQuYmVnaW4oKSwgcmVzdWx0LmVuZCgpKTsKICAgIGZvciAoYXV0byAmaXRlbSA6IHJlc3VsdCkgewogICAgICAgIGNvdXQgPDwgaXRlbS5maXJzdCA8PCAiICIgPDwgaXRlbS5zZWNvbmQgPDwgZW5kbDsKICAgIH0KICAgIAogICAgcmV0dXJuIDA7Cn0K