#include<bits/stdc++.h>
using namespace std;
int main() {
	priority_queue<pair <int, string>, vector< pair <int, string> >, greater< pair <int, string> > > pq;
	int n, k;
	cin >> n >> k;
	map<string, int> m;
	for(int i = 0; i < n; i++){
		//int x;
		string x;
		cin >> x;
		if(m.find(x) != m.end()){
			m[x] = m[x] + 1;
		}
		else{
			m[x] = 1;
		}
	}
	int i = 0;
	for(auto it = m.begin(); it != m.end(); it++){
		string s = it -> first;
		int x = it -> second;
		if(i < k){
			pq.push(make_pair(x, s));
		}
		else{
			pair <int, string> p = pq.top();
			pq.pop();
			int x1 = p.first;
			string s1 = p.second;
			if(x1 > x){
				x = x1;
				s = s1;
			}
			else if(x1 == x and s.compare(s1) > 0){
				x = x1;
				s = s1;
			}
			pq.push(make_pair(x, s));
		}
		i++;
	}
	stack<string> s;
	while(!pq.empty()){
		pair <int, string> p = pq.top();
		pq.pop();
		int x1 = p.first;
		string s1 = p.second;
		s.push(s1);
		//cout << s1 << " ";
	}
	while(!s.empty()){
		string s1 = s.top();
		cout << s1 << " ";
		s.pop();
	}
	return 0;
}