//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size == z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
						if (size >= z){
							break;
						}
					}
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size == z){
			while (z){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if (i + 1 < v.size() && pq.top().first / 2 > v[i + 1].first && pq.size() * 2 >= z){
			while (z){
				cout << pq.top().second << " ";
				z--;
				if (z <= 0){
					break;
				}
				cout << pq.top().second << " ";
				pq.pop();
				z--;
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
						if (size >= z){
							break;
						}
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if (((i + 1 < v.size() && pq.top().first / 2 >= v[i + 1].first) || i == v.size() - 1) && pq.size() * 2 >= z){
			while (z){
				cout << pq.top().second << " ";
				z--;
				if (z <= 0){
					break;
				}
				cout << pq.top().second << " ";
				pq.pop();
				z--;
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	ll s = 1, e = 2 * e15, mid;

	while (s <= e){
		mid = (s + e) / 2;
		ll sum = 0;
		if (mid){
			for (auto i : p){
				sum += (i.second / mid);
			}
		}
		if (sum >= z){
			s = mid + 1;
		}
		else{
			e = mid - 1;
		}
	}

	for (auto i : p){
		if (z <= 0){
			break;
		}
		ll n = i.second / e;
		for (int j = 0; j < n; j++){
			cout << i.first << " ";
			z--;
			if (z <= 0){
				break;
			}
		}
	}
	cout << endl;
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
					}
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z > 0){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		ll rop = pq.top().first / z;
		if (rop){
			ll rep = rop * pq.size();
			if ((i + 1 < v.size() && rop >= v[i + 1].first) && rep >= z || i == v.size() - 1 && rep >= z){
				last = (pq.size() * pq.top().first) / z;
				while (z > 0){
					for (int k = 0; k + last <= pq.top().first; k += last){
						cout << pq.top().second << " ";
						z--;
						if (z <= 0){
							break;
						}
					}
					pq.pop();
				}
				cout << endl;
				return 0;
			}
		}
		if (i == v.size() - 1){
			deque<ll>cf;
			while (pq.size()){
				cf.push_back(pq.top().second);
				pq.pop();
			}
			ll indx = 0;
			while (z){
				cout << cf[indx++] << " ";
				if (indx == cf.size()){
					indx = 0;
				}
				z--;
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size == z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
						if (size >= z){
							break;
						}
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if (((i + 1 < v.size() && pq.top().first / 2 >= v[i + 1].first)) && pq.size() * 2 >= z){
			while (z){
				cout << pq.top().second << " ";
				z--;
				if (z <= 0){
					break;
				}
				cout << pq.top().second << " ";
				pq.pop();
				z--;
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
						if (size >= z){
							break;
						}
					}
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z > 0){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if ((i + 1 < v.size() && (pq.size() * pq.top().first) / z >= v[i + 1].first) || i == v.size() - 1){
			while (z > 0){
				for (int k = 0; k < pq.top().first; k++){
					cout << pq.top().second << " ";
					z--;
					if (z <= 0){
						break;
					}
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z > 0){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if ((i + 1 < v.size() && (pq.size() * pq.top().first) / z >= v[i + 1].first) || i == v.size() - 1){
			while (z > 0){
				for (int k = 0; k < pq.top().first; k++){
					cout << pq.top().second << " ";
					z--;
					if (z <= 0){
						break;
					}
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
						if (size >= z){
							break;
						}
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if (((i + 1 < v.size() && pq.top().first / 2 > v[i + 1].first)) && pq.size() * 2 >= z){
			while (z){
				cout << pq.top().second << " ";
				z--;
				if (z <= 0){
					break;
				}
				cout << pq.top().second << " ";
				pq.pop();
				z--;
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z > 0){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		ll rop = (pq.size() * pq.top().first) / z;
		ll rep = ((pq.top().first) / rop) * pq.size();
		if ((i + 1 < v.size() && (pq.size() * pq.top().first) / z >= v[i + 1].first) && rep >= z || i == v.size() - 1 && rep >= z){
			last = (pq.size() * pq.top().first) / z;
			while (z > 0){
				for (int k = 0; k + last <= pq.top().first; k += last){
					cout << pq.top().second << " ";
					z--;
					if (z <= 0){
						break;
					}
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


//Author:Medo king
//ان الله لا يضيع اجر من احسن عملا
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <stdio.h>
#include <list>
#include <climits>
#include <map>
#include <stdlib.h>
#include <cctype>
#include <bitset>
#include <math.h>
#include <cassert>
#include <time.h>
#include <cstring>
#define ll long long
#define ld long double
#define e15 100005
#define wrong (ld)1e-16
#define PI acos(-1)
#define oo 2e18
#define MEDO_journey_TO_ICPC ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define file freopen("fruits.in","r",stdin);
#define mod (1000000007)

using namespace std;

//ll di[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
//ll dj[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

//ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
//ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }

ll x, y, z;
deque<ll>q;
priority_queue<pair<ll, ll>>pq;
deque<pair<ll, ll>>v;
map<ll, ll>p;

int main(){

	MEDO_journey_TO_ICPC;
	cin >> x >> z;
	ll sum = 0;
	for (int i = 0; i < x; i++){
		cin >> y;
		q.push_back(y);
		p[y]++;
	}

	for (auto i : p){
		v.push_back({ i.second, i.first });
	}

	sort(v.rbegin(), v.rend());
	ll last = 0;
	ll size = 0;
	if (x == z){
		for (int i = 0; i < q.size(); i++){
			cout << q[i] << " ";
		}
		cout << endl;
		return 0;
	}
	for (int i = 0; i < v.size(); i++){
		if (pq.empty()){
			last = v[i].first;
			size++;
			pq.push({ v[i].first, v[i].second });
		}
		else{
			if (pq.top().first == v[i].first){
				size++;
				pq.push(v[i]);
				last = v[i].first;
			}
			else{
				last = v[i].first;
				size = 0;
				while (pq.top().first != v[i].first){
					ll s = pq.top().first, ss = pq.top().second;
					pq.pop();
					pq.push(v[i]);
					size++;
					if (size >= z){
						break;
					}
					for (int j = 0; j + last <= s; j += last){
						pq.push({ last, ss });
						size++;
					}
					size += pq.size() - size;
					if (size >= z){
						break;
					}
				}
			}
		}
		if (size >= z){
			while (z > 0){
				if (pq.top().first == last){
					z--;
					cout << pq.top().second << " ";
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
		if ((i + 1 < v.size() && (pq.size() * pq.top().first) / z >= v[i + 1].first) || i == v.size() - 1){
			last = (pq.size() * pq.top().first) / z;
			while (z > 0){
				for (int k = 0; k + last <= pq.top().first; k += last){
					cout << pq.top().second << " ";
					z--;
					if (z <= 0){
						break;
					}
				}
				pq.pop();
			}
			cout << endl;
			return 0;
		}
	}
	return 0;
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=1;i<=2e5;i++){
        ans+=m[i]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    ll lo=1;
    ll hi=n;
    ll mid;
    while(1){

        mid=(lo+hi)/2;
        if(lo>hi) break;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    vector<ll>ans;
    for(int i=1;i<=2e5;i++){
        ll x=m[i];
        x/=mid;
        for(int j=1;j<=x;j++){
            ans.push_back(i);
            if(ans.size()==k) break;
        }
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=1;i<=2e5;i++){
        ans+=m[i]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    ll lo=1;
    ll hi=n;
    ll mid;
    while(1){

        mid=(lo+hi)/2;
        if(lo>hi) break;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    vector<ll>ans;
    for(int i=1;i<=2e5;i++){
        ll x=m[i];
        x/=mid;
        for(int j=1;j<=x;j++){
            if(ans.size()>=k) break;
            ans.push_back(i);

        }
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=m[v[i]]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(m[a[i]]==0) v.push_back(a[i]);
        m[a[i]]++;
    }
    ll lo=1;
    ll hi=n;
    ll mid;
    while(1){

        mid=(lo+hi)/2;
        if(lo>hi) break;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    for(int i=0;i<v.size();i++){
        ll x=m[v[i]];
        x/=mid;
        for(int j=1;j<=x;j++){
            cout<<v[i]<<" ";
        }
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=m[v[i]]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(m[a[i]]==0) v.push_back(a[i]);
        m[a[i]]++;
    }
    ll lo=0;
    ll hi=k;
    ll mid;
    while(lo<=hi){
        mid=(lo+hi)/2;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    for(int i=0;i<v.size();i++){
        ll x=m[v[i]];
        x/=mid;
        for(int j=1;j<=x;j++){
            cout<<v[i]<<" ";
        }
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=m[v[i]]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(m[a[i]]==0) v.push_back(a[i]);
        m[a[i]]++;
    }
    ll lo=0;
    ll hi=n;
    ll mid;
    while(lo<=hi){
        mid=(lo+hi)/2;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    if(f(mid+1)==1){
        mid++;
    }
    else{
        if(f(mid)==0){
            mid--;
        }
    }
    for(int i=0;i<v.size();i++){
        ll x=m[v[i]];
        x/=mid;
        for(int j=1;j<=x;j++){
            cout<<v[i]<<" ";
        }
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=1;i<=2e5;i++){
        ans+=m[i]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    ll lo=1;
    ll hi=n;
    ll mid;
    while(1){

        mid=(lo+hi)/2;
        if(lo>hi) break;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    if(mid>k) mid--;
    vector<ll>ans;
    for(int i=1;i<=2e5;i++){
        ll x=m[i];
        x/=mid;
        for(int j=1;j<=x;j++){
            if(ans.size()>=k) break;
            ans.push_back(i);

        }
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=m[v[i]]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(m[a[i]]==0) v.push_back(a[i]);
        m[a[i]]++;
    }
    ll lo=0;
    ll hi=n;
    ll mid;
    while(1){

        mid=(lo+hi)/2;
        if(lo==hi || lo==mid || hi==mid) break;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    mid--;
    for(int i=0;i<v.size();i++){
        ll x=m[v[i]];
        x/=mid;
        for(int j=1;j<=x;j++){
            cout<<v[i]<<" ";
        }
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=m[v[i]]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(m[a[i]]==0) v.push_back(a[i]);
        m[a[i]]++;
    }
    ll lo=1;
    ll hi=n;
    ll mid;
    while(1){

        mid=(lo+hi)/2;
        if(lo>hi) break;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    vector<ll>ans;
    for(int i=0;i<v.size();i++){
        ll x=m[v[i]];
        x/=mid;
        for(int j=1;j<=x;j++){

            if(ans.size()>=k) break;
            ans.push_back(v[i]);

        }
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=m[v[i]]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(m[a[i]]==0) v.push_back(a[i]);
        m[a[i]]++;
    }
    ll lo=0;
    ll hi=n;
    ll mid;
    while(1){

        mid=(lo+hi)/2;
        if(lo>hi) break;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    for(int i=0;i<v.size();i++){
        ll x=m[v[i]];
        x/=mid;
        for(int j=1;j<=x;j++){
            cout<<v[i]<<" ";
        }
    }
    cout<<endl;
   return(0);
}


#include <stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 500008
#define ll int
ll bigmod(ll base, ll power, ll mod)
{
    if(power==0)    return 1;
    else if(power%2==1){
        ll p1 = base % mod;
        ll p2 = (bigmod(base,power-1,mod))%mod;
        return (p1*p2)%mod;
    }
    else if(power%2==0){
        ll p1 = (bigmod(base,power/2,mod))%mod;
        return (p1*p1)%mod;
    }
}
ll ncr(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= min(i, k); j++) {
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    return C[n][k];
}
ll prime[mx];
ll sp[mx];
void seive()
{
    for(int i=2;i<=mx;i+=2) sp[i]=2;
    for(int i=3;i<=mx;i+=2) sp[i]=i;
    ll x=sqrt(mx);
    for(int i=3;i<=x;i+=2){
        if(sp[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                sp[j]=i;
            }
        }
    }
}
vector<ll>v;
void pf(ll n)
{
    ll m=n;
    while(1){
        if(m<=1) break;
        ll x=sp[m];
        while(m%x==0){
            m/=x;
        }
    }
}
ll a[mx];

map<ll,ll>m;
ll n,k;
ll f(ll mid)
{
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=m[v[i]]/mid;
    }
    if(ans>=k) return 1;
    else return 0;
}
int main () {

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(m[a[i]]==0) v.push_back(a[i]);
        m[a[i]]++;
    }
    ll lo=1;
    ll hi=n;
    ll mid;
    while(1){

        mid=(lo+hi)/2;
        if(lo>hi) break;
        if(f(mid)){
            lo=mid+1;
        }
        else hi=mid-1;
    }
    vector<ll>ans;
    for(int i=0;i<v.size();i++){
        ll x=m[v[i]];
        x/=mid;
        for(int j=1;j<=x;j++){
            ans.push_back(v[i]);
            if(ans.size()==k) break;
        }
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
   return(0);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
// #define pop pop_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 7;
const ll INF = 1e17;

const ll mod = (ll)1e9 + 7;

void solve()
{
    ll n, k; cin >> n >> k; vector <ll> a(n);
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    map <ll, ll> mp;
    for(ll it : a)
        mp[it] ++;
    vector <pair<ll, ll>> aa;
    for(auto i : mp)
    {
        aa.push_back({i.second, i.first});
    }
    vector <pair <ll, ll>> mine;
    for(auto i : aa)
    {
        ll x = i.first; ll y = i.second;
        while(x > 0)
        {
            mine.push_back({x, y});
            x /= 2;
        }
    }
    sort(mine.rbegin(), mine.rend());
    for(ll i = 0; i < k; i++)
    {
        cout << mine[i].second << ' ';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
// #define pop pop_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 7;
const ll INF = 1e17;

const ll mod = (ll)1e9 + 7;

bool can(vector <ll> a, ll x, ll k)
{
    ll sum = 0;
    for(auto y : a)
        sum += (y / x);
    if (sum >= k)
        return true;
    return false;
}

void solve()
{
    ll n, k; cin >> n >> k; vector <ll> a(n);
    vector <ll> counts; map <int, int> mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[ a[i] ] ++;
    }

    vector <pair <ll,ll> > neopolitan;
    for(auto x : mp)
    {
        counts.push_back(x.second);
        neopolitan.push_back({x.second, x.first});
    }

    ll i = 1, j = n, mid;
    while(i < j - 1)
    {
        mid = (i+j)/2;
        if(can(counts, mid, k))
            i = mid;
        else
            j = mid;
    }
    sort(neopolitan.rbegin(), neopolitan.rend());
    ll sum = 0;
    for(auto x : neopolitan)
    {
        sum += x.first/i;
        for(int p = 0; p < min(x.first/i, k - sum + x.first/i); p++)
            cout << x.second << ' ';
        if (sum >= k)
            break;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
// #define pop pop_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 7;
const ll INF = 1e17;

const ll mod = (ll)1e9 + 7;

bool can(vector <ll> a, ll x, ll k)
{
    ll sum = 0;
    for(auto y : a)
        sum += (y / x);
    if (sum >= k)
        return true;
    return false;
}

void solve()
{
    ll n, k; cin >> n >> k; vector <ll> a(n);
    vector <ll> counts; map <int, int> mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[ a[i] ] ++;
    }

    vector <pair <ll,ll> > neopolitan;
    for(auto x : mp)
    {
        counts.push_back(x.second);
        neopolitan.push_back({x.second, x.first});
    }

    ll i = 1, j = n, mid;
    while(i < j - 1)
    {
        mid = (i+j)/2;
        if(can(counts, mid, k))
            i = mid;
        else
            j = mid;
    }
    sort(neopolitan.rbegin(), neopolitan.rend());
    ll sum = 0;
    for(auto x : neopolitan)
    {
        sum += x.first/i;
        for(int p = 0; p < min(x.first/i, k); p++)
            cout << x.second << ' ';
        if (sum >= k)
            break;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
// #define pop pop_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 7;
const ll INF = 1e17;

const ll mod = (ll)1e9 + 7;

bool can(vector <ll> a, ll x, ll k)
{
    ll sum = 0;
    for(auto y : a)
        sum += (y / x);
    if (sum >= k)
        return true;
    return false;
}

void solve()
{
    ll n, k; cin >> n >> k; vector <ll> a(n);
    vector <ll> counts; map <int, int> mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[ a[i] ] ++;
    }

    vector <pair <ll,ll> > neopolitan;
    for(auto x : mp)
    {
        counts.push_back(x.second);
        neopolitan.push_back({x.second, x.first});
    }

    ll i = 0, j = n, mid;
    while(i < j - 1)
    {
        mid = (i+j)/2;
        if(can(counts, mid, k))
            i = mid;
        else
            j = mid;
    }
    sort(neopolitan.rbegin(), neopolitan.rend());
    ll sum = 0;
    for(auto x : neopolitan)
    {
        sum += x.first/i;
        for(int p = 0; p < min(x.first/i, k); p++)
            cout << x.second << ' ';
        if (sum >= k)
            break;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
// #define pop pop_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 7;
const ll INF = 1e17;

const ll mod = (ll)1e9 + 7;

bool can(vector <ll> a, ll x, ll k)
{
    ll sum = 0;
    for(auto y : a)
        sum += (y / x);
    if (sum >= k)
        return true;
    return false;
}

void solve()
{
    ll n, k; cin >> n >> k; vector <ll> a(n);
    vector <ll> counts; map <int, int> mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[ a[i] ] ++;
    }

    vector <pair <ll,ll> > neopolitan;
    for(auto x : mp)
    {
        counts.push_back(x.second);
        neopolitan.push_back({x.second, x.first});
    }

    ll i = 0, j = n, mid;
    while(i < j - 1)
    {
        mid = (i+j)/2;
        if(can(counts, mid, k))
            i = mid;
        else
            j = mid;
    }
    sort(neopolitan.rbegin(), neopolitan.rend());
    ll sum = 0;
    for(auto x : neopolitan)
    {
        sum += x.first/i;
        for(int j = 0; j < x.first/i; j++)
            cout << x.second << ' ';
        if (sum >= k)
            break;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
// #define pop pop_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 7;
const ll INF = 1e17;

const ll mod = (ll)1e9 + 7;

int n, k;
vector <int> s, t;
vector <int> cnts(N);

bool can(int cnt)
{
    t.clear();
    for(int i = 0; i < N; ++i)
    {
        int need = min(cnts[i] / cnt, k - int(t.size()));
        for(int j = 0; j < need; j++)
            t.push_back(i);
    }
    return (int(t.size()) == k);
}

void solve()
{
    cin >> n >> k;
    s = vector <int> (n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for(auto c : s)
        ++cnts[c];
    int l = 0, r = n;
    while(l < r - 1)
    {
        int mid = (l+r) >> 1;
        if(can(mid))
            l = mid;
        else
            r = mid;
    }

    if( ! can(r))
        can(l);

    for(auto it: t)
        cout << it << ' ';
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
// #define pop pop_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 7;
const ll INF = 1e17;

const ll mod = (ll)1e9 + 7;

void solve()
{
    ll n, k; cin >> n >> k; vector <ll> a(n);
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    map <ll, ll> mp;
    for(ll it : a)
        mp[it] ++;
    vector <pair<ll, ll>> aa;
    for(auto i : mp)
    {
        aa.push_back({i.second, i.first});
    }
    vector <pair <ll, ll>> mine;
    for(auto i : aa)
    {
        ll x = i.first; ll y = i.second;
        int j = 1;
        while((x / j) > 0)
        {
            mine.push_back({x / j, y});
            j++;
        }
    }
    sort(mine.rbegin(), mine.rend());
    for(ll i = 0; i < k; i++)
    {
        cout << mine[i].second << ' ';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
// #define pop pop_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 7;
const ll INF = 1e17;

const ll mod = (ll)1e9 + 7;

bool can(vector <ll> a, ll x, ll k)
{
    ll sum = 0;
    for(auto y : a)
        sum += (y / x);
    if (sum >= k)
        return true;
    return false;
}

void solve()
{
    ll n, k; cin >> n >> k; vector <ll> a(n);
    vector <ll> counts; map <int, int> mp;
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
        mp[ a[i] ] ++;
    }

    vector <pair <ll,ll> > neopolitan;
    for(auto x : mp)
    {
        counts.push_back(x.second);
        neopolitan.push_back({x.second, x.first});
    }

    ll i = 0, j = n, mid;
    while(i < j - 1)
    {
        mid = (i+j)/2;
        if(can(counts, mid, k))
            i = mid;
        else
            j = mid;
    }
    sort(neopolitan.rbegin(), neopolitan.rend());
    ll sum = 0;
    cout << i << '\n';
    for(auto x : neopolitan)
    {
        sum += x.first/i;
        for(int j = 0; j < x.first/i; j++)
            cout << x.second << ' ';
        if (sum >= k)
            break;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // int t; cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    bool sortbysec(pair <int,int> p1, pair <int,int> p2)
    {
          return (p2.second<p1.second);
    }
    int main()
    {
         int n,k;
         cin>>n>>k;

         vector <pair<int,int>> freq(200002,make_pair(0,0));
         for(int i=0;i<n;i++)
         {
               int a;
               cin>>a;
             int x=freq[a].second;
             freq[a].first=a;
             freq[a].second=x+1;

         }

         sort(freq.begin(),freq.end(),sortbysec);

       int hi=freq[0].second;
       int lo=freq[k-1].second;
       int ans;
       while(lo<=hi)
       {

             int mid=lo+(hi-lo)/2;

                   int cnt=0;
             for(int i=0;i<k;i++)
             {

                 cnt+=(freq[i].second)/mid;

                   if(cnt>=k)
                   {
                         break;
                   }
             }

             if(cnt>=k)
             {
                   ans=mid;
                  lo=mid+1;

             }
             else if(cnt<k)
             {
                   hi=mid-1;
             }
       }

         int cnt=0;
         int flag=0;
       //  cout<<ans<<endl;
      for(int i=0;i<k;i++)
             {

                   while(freq[i].second-ans>=0)
                   {

                         freq[i].second-=ans;
                         cout<<freq[i].first<<" ";

                         cnt++;

                         if(cnt==k)
                         {
                               flag=1;
                               break;
                         }
                   }

                   if(cnt>=k || flag==1 )
                   {
                         break;
                   }
             }

         return 0;
    }


#include <bits/stdc++.h>
using namespace std;
bool sortbysec(pair <int,int> p1, pair <int,int> p2)
{
      return (p2.second<p1.second);
}
int main()
{
     int n,k;
     cin>>n>>k;
     vector <int> temp(200005,0);
     vector <pair<int,int>> freq;
     for(int i=0;i<n;i++)
     {
           int a;
           cin>>a;
          temp[a]++;

     }
     for(int i=0;i<temp.size();i++)
     {
           if(temp[i]>0)
           {
                     freq.push_back(make_pair(i,temp[i]));
           }

     }
     sort(freq.begin(),freq.end(),sortbysec);

   int hi=freq[0].second;
   int lo=freq[k-1].second;
   int ans;
   while(lo<=hi)
   {

         int mid=lo+(hi-lo)/2;

               int cnt=0;
         for(int i=0;i<k;i++)
         {

             cnt+=(freq[i].second)/mid;

               if(cnt>=k)
               {
                     break;
               }
         }

         if(cnt>=k)
         {
               ans=mid;
              lo=mid+1;

         }
         else if(cnt<k)
         {
               hi=mid-1;
         }
   }

     int cnt=0;
  for(int i=0;i<k;i++)
         {

               while(freq[i].second-ans>=0)
               {

                     freq[i].second-=ans;

                     cnt++;
                     cout<<freq[i].first<<" ";
               }

               if(cnt==k)
               {
                     break;
               }
         }

     return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool sortbysec(pair <int,int> p1, pair <int,int> p2)
{
      return (p2.second<p1.second);
}
int main()
{
     int n,k;
     cin>>n>>k;
     vector <int> temp(100005,0);
     vector <pair<int,int>> freq;
     for(int i=0;i<n;i++)
     {
           int a;
           cin>>a;
          temp[a]++;

     }
     for(int i=0;i<temp.size();i++)
     {
           if(temp[i]>0)
           {
                     freq.push_back(make_pair(i,temp[i]));
           }

     }
     sort(freq.begin(),freq.end(),sortbysec);

   int hi=freq[0].second;
   int lo=freq[k-1].second;
   int ans;
   while(lo<=hi)
   {

         int mid=lo+(hi-lo)/2;

               int cnt=0;
         for(int i=0;i<k;i++)
         {

             cnt+=(freq[i].second)/mid;

               if(cnt>=k)
               {
                     break;
               }
         }

         if(cnt>=k)
         {
               ans=mid;
              lo=mid+1;

         }
         else if(cnt<k)
         {
               hi=mid-1;
         }
   }

     int cnt=0;
  for(int i=0;i<k;i++)
         {

               while(freq[i].second-ans>=0)
               {

                     freq[i].second-=ans;

                     cnt++;
                     cout<<freq[i].first<<" ";
               }

               if(cnt==k)
               {
                     break;
               }
         }

     return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    bool sortbysec(pair <int,int> p1, pair <int,int> p2)
    {
          return (p2.second<p1.second);
    }
    int main()
    {
         int n,k;
         cin>>n>>k;

         vector <pair<int,int>> freq(200002,make_pair(0,0));
         for(int i=0;i<n;i++)
         {
               int a;
               cin>>a;
             int x=freq[a].second;
             freq[a].first=a;
             freq[a].second=x+1;

         }

         sort(freq.begin(),freq.end(),sortbysec);

       int hi=freq[0].second;
       int lo=freq[k-1].second;
       int ans;
       while(lo<=hi)
       {

             int mid=lo+(hi-lo)/2;

                   int cnt=0;
             for(int i=0;i<k;i++)
             {

                 cnt+=(freq[i].second)/mid;

                   if(cnt>=k)
                   {
                         break;
                   }
             }

             if(cnt>=k)
             {
                   ans=mid;
                  lo=mid+1;

             }
             else if(cnt<k)
             {
                   hi=mid-1;
             }
       }

         int cnt=0;
      for(int i=0;i<k;i++)
             {

                   while(freq[i].second-ans>=0)
                   {

                         freq[i].second-=ans;

                         cnt++;
                         cout<<freq[i].first<<" ";
                   }

                   if(cnt==k)
                   {
                         break;
                   }
             }

         return 0;
    }


#include <bits/stdc++.h>
using namespace std;
bool sortbysec(pair <int,int> p1, pair <int,int> p2)
{
      return (p2.second<p1.second);
}
int main()
{
     int n,k;
     cin>>n>>k;
     vector <int> temp(200005,0);
     vector <pair<int,int>> freq;
     for(int i=0;i<n;i++)
     {
           int a;
           cin>>a;
          temp[a]++;

     }
     for(int i=0;i<temp.size();i++)
     {
        freq.push_back(make_pair(i,temp[i]+1));
     }
     sort(freq.begin(),freq.end(),sortbysec);

   int hi=freq[0].second;
   int lo=freq[k-1].second;
   int ans;
   while(lo<=hi)
   {

         int mid=lo+(hi-lo)/2;

               int cnt=0;
         for(int i=0;i<k;i++)
         {

             cnt+=(freq[i].second)/mid;

               if(cnt>=k)
               {
                     break;
               }
         }

         if(cnt>=k)
         {
               ans=mid;
              lo=mid+1;

         }
         else if(cnt<k)
         {
               hi=mid-1;
         }
   }

     int cnt=0;
  for(int i=0;i<k;i++)
         {

               while(freq[i].second-ans>=0)
               {

                     freq[i].second-=ans;

                     cnt++;
                     cout<<freq[i].first<<" ";
               }

               if(cnt==k)
               {
                     break;
               }
         }

     return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    bool sortbysec(pair <int,int> p1, pair <int,int> p2)
    {
          return (p2.second<p1.second);
    }
    int main()
    {
         int n,k;
         cin>>n>>k;
         vector <int> temp(200005,0);
         vector <pair<int,int>> freq;
         for(int i=0;i<n;i++)
         {
               int a;
               cin>>a;
              temp[a]++;

         }
         for(int i=0;i<temp.size();i++)
         {
            freq.push_back(make_pair(i,temp[i]));
         }
         sort(freq.begin(),freq.end(),sortbysec);

       int hi=freq[0].second;
       int lo=freq[k-1].second;
       int ans;
       while(lo<=hi)
       {

             int mid=lo+(hi-lo)/2;

                   int cnt=0;
             for(int i=0;i<k;i++)
             {

                 cnt+=(freq[i].second)/mid;

                   if(cnt>=k)
                   {
                         break;
                   }
             }

             if(cnt>=k)
             {
                   ans=mid;
                  lo=mid+1;

             }
             else if(cnt<k)
             {
                   hi=mid-1;
             }
       }

         int cnt=0;
      for(int i=0;i<k;i++)
             {

                   while(freq[i].second-ans>=0)
                   {

                         freq[i].second-=ans;

                         cnt++;
                         cout<<freq[i].first<<" ";
                   }

                   if(cnt>=k)
                   {
                         break;
                   }
             }

         return 0;
    }


    #include <bits/stdc++.h>
    using namespace std;
    bool sortbysec(pair <int,int> p1, pair <int,int> p2)
    {
          return (p2.second<p1.second);
    }
    int main()
    {
         int n,k;
         cin>>n>>k;

         vector <pair<int,int>> freq(200002,make_pair(0,0));
         for(int i=0;i<n;i++)
         {
               int a;
               cin>>a;
             int x=freq[a].second;
             freq[a].first=a;
             freq[a].second=x+1;

         }

         sort(freq.begin(),freq.end(),sortbysec);

       int hi=freq[0].second;
       int lo=freq[k-1].second;
       int ans;
       while(lo<=hi)
       {

             int mid=lo+(hi-lo)/2;

                   int cnt=0;
             for(int i=0;i<k;i++)
             {

                 cnt+=(freq[i].second)/mid;

                   if(cnt>=k)
                   {
                         break;
                   }
             }

             if(cnt>=k)
             {
                   ans=mid;
                  lo=mid+1;

             }
             else if(cnt<k)
             {
                   hi=mid-1;
             }
       }

         int cnt=0;
      for(int i=0;i<k;i++)
             {

                   while(freq[i].second-ans>=0)
                   {

                         freq[i].second-=ans;

                         cnt++;
                         cout<<freq[i].first<<" ";
                   }

                   if(cnt>=k)
                   {
                         break;
                   }
             }

         return 0;
    }


#include <bits/stdc++.h>
using namespace std;
bool sortbysec(pair <int,int> p1, pair <int,int> p2)
{
      return (p2.second<p1.second);
}
int main()
{
     int n,k;
     cin>>n>>k;
     int temp[250000]={0};
     vector <pair<int,int>> freq;
     for(int i=0;i<n;i++)
     {
           int a;
           cin>>a;
          temp[a]++;

     }
     for(int i=0;i<250000;i++)
     {
           if(temp[i]>0)
           {
                     freq.push_back(make_pair(i,temp[i]));
           }

     }
     sort(freq.begin(),freq.end(),sortbysec);

   int hi=freq[0].second;
   int lo=freq[k-1].second;
   int ans;
   while(lo<=hi)
   {

         int mid=lo+(hi-lo)/2;

               int cnt=0;
         for(int i=0;i<k;i++)
         {

             cnt+=(freq[i].second)/mid;

               if(cnt>=k)
               {
                     break;
               }
         }

         if(cnt>=k)
         {
               ans=mid;
              lo=mid+1;

         }
         else if(cnt<k)
         {
               hi=mid-1;
         }
   }

     int cnt=0;
  for(int i=0;i<k;i++)
         {

               while(freq[i].second-ans>=0)
               {

                     freq[i].second-=ans;

                     cnt++;
                     cout<<freq[i].first<<" ";
               }

               if(cnt==k)
               {
                     break;
               }
         }

     return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    bool sortbysec(pair <int,int> p1, pair <int,int> p2)
    {
          return (p2.second<p1.second);
    }
    int main()
    {
         int n,k;
         cin>>n>>k;

         vector <pair<int,int>> freq(200002,make_pair(0,0));
         for(int i=0;i<n;i++)
         {
               int a;
               cin>>a;
             int x=freq[a].second;
             freq[a].first=a;
             freq[a].second=x+1;

         }

         sort(freq.begin(),freq.end(),sortbysec);

       int hi=freq[0].second;
       int lo=freq[k].second;
       int ans;
       while(lo<=hi)
       {

             int mid=lo+(hi-lo)/2;

                   int cnt=0;
             for(int i=0;i<k;i++)
             {

                 cnt+=(freq[i].second)/mid;

                   if(cnt>=k)
                   {
                         break;
                   }
             }

             if(cnt>=k)
             {
                   ans=mid;
                  lo=mid+1;

             }
             else if(cnt<k)
             {
                   hi=mid-1;
             }
       }

         int cnt=0;
         int flag=1;
      for(int i=0;i<k;i++)
             {
                   //cout<<freq[i].first<<" "<<freq[i].second<<endl;

                 for(int j=0;j<((freq[i].second)/ans);j++)
                 {
                        cout<<freq[i].first<<" ";

                         cnt++;
                                  if(cnt==k)
                   {
                         break;
                         flag=0;
                   }

                   }
                   if(flag==0)
                   {
                         break;
                   }

             }

         return 0;
    }


#include <bits/stdc++.h>
using namespace std;
bool sortbysec(pair <int,int> p1, pair <int,int> p2)
{
      return (p2.second<p1.second);
}
int main()
{
     int n,k;
     cin>>n>>k;
     vector <pair<int,int>> freq(200005,make_pair(0,0));
     for(int i=0;i<n;i++)
     {
           int a;
           cin>>a;

           int x=freq[a].second;

           freq[a].first=a;
           freq[a].second=x+1;

     }
     sort(freq.begin(),freq.end(),sortbysec);

   int hi=freq[0].second;
   int lo=freq[k-1].second;
   int ans;
   while(lo<=hi)
   {

         int mid=lo+(hi-lo)/2;

          vector <pair<int,int>> cpy;

               for(int i=0;i<k;i++)
               {
                     cpy.push_back(make_pair(freq[i].first,freq[i].second));
               }
               int cnt=0;
         for(int i=0;i<k;i++)
         {

               while(cpy[i].second-mid>=0)
               {

                     cpy[i].second-=mid;

                     cnt++;
               }

               if(cnt==k)
               {
                     break;
               }
         }

         if(cnt==k)
         {
               ans=mid;
              lo=mid+1;

         }
         else if(cnt<k)
         {
               hi=mid-1;
         }
   }

     int cnt=0;
  for(int i=0;i<k;i++)
         {

               while(freq[i].second-ans>=0)
               {

                     freq[i].second-=ans;

                     cnt++;
                     cout<<freq[i].first<<" ";
               }

               if(cnt==k)
               {
                     break;
               }
         }

     return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool sortbysec(pair <int,int> p1, pair <int,int> p2)
{
      return (p2.second<p1.second);
}
int main()
{
     int n,k;
     cin>>n>>k;
     vector <pair<int,int>> freq(100005,make_pair(0,0));
     for(int i=0;i<n;i++)
     {
           int a;
           cin>>a;

           int x=freq[a].second;

           freq[a].first=a;
           freq[a].second=x+1;

     }
     sort(freq.begin(),freq.end(),sortbysec);

     int cnt=0;
   int hi=freq[0].second;
   int lo=freq[k-1].second;
   vector <int> ans;
   while(lo<=hi)
   {

         int mid=lo+(hi-lo)/2;

          vector <pair<int,int>> cpy;
            vector <int> t_temp;
               for(int i=0;i<k;i++)
               {
                     cpy.push_back(make_pair(freq[i].first,freq[i].second));
               }
               int cnt=0;
         for(int i=0;i<k;i++)
         {

               while(cpy[i].second-mid>=0)
               {

                     cpy[i].second-=mid;
                     t_temp.push_back(cpy[i].first);
                     cnt++;
               }

               if(cnt==k)
               {
                     break;
               }
         }

         if(cnt==k)
         {
               ans.clear();
              for(int i=0;i<t_temp.size();i++)
              {
                    ans.push_back(t_temp[i]);
              }
              lo=mid+1;

         }
         else if(cnt<k)
         {
               hi=mid-1;
         }
   }
  for(int i=0;i<ans.size();i++)
  {
        cout<<ans[i]<<" ";
  }

     return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    bool sortbysec(pair <int,int> p1, pair <int,int> p2)
    {
          return (p2.second<p1.second);
    }
    int main()
    {
         int n,k;
         cin>>n>>k;

         vector <pair<int,int>> freq(200002,make_pair(0,0));
         for(int i=0;i<n;i++)
         {
               int a;
               cin>>a;
             int x=freq[a].second;
             freq[a].first=a;
             freq[a].second=x+1;

         }

         sort(freq.begin(),freq.end(),sortbysec);

       int hi=freq[0].second;
       int lo=freq[k].second;
       int ans;
       while(lo<=hi)
       {

             int mid=lo+(hi-lo)/2;

                   int cnt=0;
             for(int i=0;i<k;i++)
             {

                 cnt+=(freq[i].second)/mid;

                   if(cnt>=k)
                   {
                         break;
                   }
             }

             if(cnt>=k)
             {
                   ans=mid;
                  lo=mid+1;

             }
             else if(cnt<k)
             {
                   hi=mid-1;
             }
       }

         int cnt=0;
      for(int i=0;i<k;i++)
             {
                   //cout<<freq[i].first<<" "<<freq[i].second<<endl;

                 for(int j=0;j<((freq[i].second)/ans);j++)
                 {
                        cout<<freq[i].first<<" ";

                         cnt++;
                                  if(cnt==k)
                   {
                         break;
                   }

                   }

             }

         return 0;
    }


#include <bits/stdc++.h>
using namespace std;
bool sortbysec(pair <int,int> p1, pair <int,int> p2)
{
      return (p2.second<p1.second);
}
int main()
{
     int n,k;
     cin>>n>>k;
     vector <int> temp(200005,0);
     vector <pair<int,int>> freq;
     for(int i=0;i<n;i++)
     {
           int a;
           cin>>a;
          temp[a]++;

     }
     for(int i=0;i<temp.size();i++)
     {
        freq.push_back(make_pair(i,temp[i]+1));
     }
     sort(freq.begin(),freq.end(),sortbysec);

   int hi=freq[0].second;
   int lo=freq[k-1].second;
   int ans;
   while(lo<=hi)
   {

         int mid=lo+(hi-lo)/2;

               int cnt=0;
         for(int i=0;i<k;i++)
         {

             cnt+=(freq[i].second)/mid;

               if(cnt>=k)
               {
                     break;
               }
         }

         if(cnt>=k)
         {
               ans=mid;
              lo=mid+1;

         }
         else if(cnt<k)
         {
               hi=mid-1;
         }
   }

     int cnt=0;
  for(int i=0;i<k;i++)
         {

               while(freq[i].second-ans>=0)
               {

                     freq[i].second-=ans;

                     cnt++;
                     cout<<freq[i].first<<" ";
               }

               if(cnt>=k)
               {
                     break;
               }
         }

     return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool sortbysec(pair <int,int> p1, pair <int,int> p2)
{
      return (p2.second<p1.second);
}
int main()
{
     int n,k;
     cin>>n>>k;
     vector <int> temp(300005,0);
     vector <pair<int,int>> freq;
     for(int i=0;i<n;i++)
     {
           int a;
           cin>>a;
          temp[a]++;

     }
     for(int i=0;i<temp.size();i++)
     {
           if(temp[i]>0)
           {
                     freq.push_back(make_pair(i,temp[i]));
           }

     }
     sort(freq.begin(),freq.end(),sortbysec);

   int hi=freq[0].second;
   int lo=freq[k-1].second;
   int ans;
   while(lo<=hi)
   {

         int mid=lo+(hi-lo)/2;

               int cnt=0;
         for(int i=0;i<k;i++)
         {

             cnt+=(freq[i].second)/mid;

               if(cnt>=k)
               {
                     break;
               }
         }

         if(cnt>=k)
         {
               ans=mid;
              lo=mid+1;

         }
         else if(cnt<k)
         {
               hi=mid-1;
         }
   }

     int cnt=0;
  for(int i=0;i<k;i++)
         {

               while(freq[i].second-ans>=0)
               {

                     freq[i].second-=ans;

                     cnt++;
                     cout<<freq[i].first<<" ";
               }

               if(cnt==k)
               {
                     break;
               }
         }

     return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  // vector quantidade indice==numeero
  vector<bool> dupls(200006);
  vector<pair<ll,ll> > qtd(200006,{0,0});
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    qtd[a].first++;
    qtd[a].second=a;
  }
  ll p=k-1;
  sort(qtd.begin(),qtd.end());
  reverse(qtd.begin(),qtd.end());
  for(int i=k-1;i>=0;i--){
    if(qtd[i].first/2>qtd[p].first){
      dupls[i]=true;
      p-=1;
    }
  }
  for(int i=0;i<=p;i++){
    cout<<qtd[i].second<<" ";
    if(dupls[i])cout<<qtd[i].second<<" ";
  }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  // vector quantidade indice==numeero
  vector<bool> dupls(200006);
  vector<pair<ll,ll> > qtd(200006,{0,0});
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    qtd[a].first++;
    qtd[a].second=a;
  }
  ll p=k-1;
  ll ult=p;
  sort(qtd.begin(),qtd.end());
  reverse(qtd.begin(),qtd.end());
  for(int i=k-1;i>=0;i--){
    if(dupls[p]==true){
      p-=1;
      i+=1;
      continue;
    }
    if(dupls[i]==true)continue;
    if(qtd[i].first/2>qtd[p].first){
      dupls[i]=true;
      p-=1;
      ult-=1;
    }
  }
  for(int i=0;i<=ult;i++){
    cout<<qtd[i].second<<" ";
    if(dupls[i])cout<<qtd[i].second<<" ";
  }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  // vector quantidade indice==numeero
  vector<bool> dupls(200006);
  vector<pair<ll,ll> > qtd(200006,{0,0});
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    qtd[a].first++;
    qtd[a].second=a;
  }
  ll p=k-1;
  sort(qtd.begin(),qtd.end());
  reverse(qtd.begin(),qtd.end());
  for(int i=k-1;i>=0;i--){
    if(dupls[p]==true){
      p-=1;
      i+=1;
      continue;
    }
    if(qtd[i].first/2>qtd[p].first){
      dupls[i]=true;
      p-=1;
    }
  }
  for(int i=0;i<=p;i++){
    cout<<qtd[i].second<<" ";
    if(dupls[i])cout<<qtd[i].second<<" ";
  }
}


using namespace std;
int main()
{
  // vector quantidade indice==numero
  vector<bool> dupls(200006);
  vector<pair<ll,ll> > qtd(200006,{0,0});
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    qtd[a].first++;
    qtd[a].second=a;
  }
  ll p=k-1;
  ll ult=p;
  sort(qtd.begin(),qtd.end());
  reverse(qtd.begin(),qtd.end());
  for(int i=k-1;i>=0;i--){
    if(dupls[p]==true){
      p-=1;
      i+=1;
      continue;
    }
    if(dupls[i]==true)continue;
    if(qtd[i].first/2>=qtd[p].first){
     qtd[p].first=0;
      dupls[i]=true;
      p-=1;
      ult-=1;
    }
  }
  for(int i=0;i<=ult;i++){
    if(qtd[i].first!=0)cout<<qtd[i].second<<" ";
    if(dupls[i] && qtd[i].first!=0)cout<<qtd[i].second<<" ";
  }
}


#include<bits/stdc++.h>
#define debug(a) cout<<a<<endl
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,cont[200010],lft[200010],f;
    memset(cont,0,sizeof(cont));
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        cont[a]++;
    }
    int ini=1,fim=200010;
    while(ini<=fim){
        int meio=(ini+fim)/2;
        int qtd=0;
        for(int i=1;i<200010;i++){
            qtd+=cont[i]/meio;
        }
        if(qtd<k)fim=meio-1;
        else ini=meio+1;
    }
    vector<int> ans;
    for(int i =1;i<200010;i++){
        while(ans.size()<k && cont[i]>=fim){
            cont[i]-=fim;
            ans.push_back(i);
        }
    }
    for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
    cout<<'\n';
    return 0;
}


#include<bits/stdc++.h>
#define debug(a) cout<<a<<endl
using namespace std;
int main()
{
    int n,k,cont[200010],lft[200010];
    memset(cont,0,sizeof(cont));
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        cont[a]++;
    }
    int ini=1,fim=200010;
    while(ini<=fim){
        int meio=(ini+fim)/2;
        int qtd=0;
        for(int i=1;i<200010;i++){
            qtd+=cont[i]/meio;
        }
        if(qtd<k)fim=meio-1;
        else ini=meio+1;
    }
    vector<int> ans;
    for(int i =1;i<200010;i++){
        while(ans.size()<k && cont[i]>=fim){
            cont[i]-=fim;
            ans.push_back(i);
        }
    }
    for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
    cout<<'\n';
    return 0;
}


#include<bits/stdc++.h>
#define debug(a) cout<<a<<endl
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,cont[200010],lft[200010];
    memset(cont,0,sizeof(cont));
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        cont[a]++;
    }
    int ini=1,fim=200010;
    while(ini<=fim){
        int meio=(ini+fim)/2;
        int qtd=0;
        for(int i=1;i<200010;i++){
            qtd+=cont[i]/meio;
        }
        if(qtd<k)fim=meio-1;
        else ini=meio+1;
    }
    vector<int> ans;
    for(int i =1;i<200010;i++){
        while(ans.size()<k && cont[i]>=fim){
            cont[i]-=fim;
            ans.push_back(i);
        }
    }
    for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
    cout<<'\n';
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  // vector quantidade indice==numero
  vector<bool> dupls(200006);
  vector<pair<ll,ll> > qtd(200006,{0,0});
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    qtd[a].first++;
    qtd[a].second=a;
  }
  ll p=k-1;
  ll ult=p;
  sort(qtd.begin(),qtd.end());
  reverse(qtd.begin(),qtd.end());
  for(int i=k-1;i>=0;i--){
    if(dupls[p]==true){
      p-=1;
      i+=1;
      continue;
    }
    if(dupls[i]==true)continue;
    if(qtd[i].first/2>=qtd[p].first){
     qtd[p].first=0;
      dupls[i]=true;
      p-=1;
      ult-=1;
    }
  }
  for(int i=0;i<=ult;i++){
    if(qtd[i].first!=0)cout<<qtd[i].second<<" ";
    if(dupls[i] && qtd[i].first!=0)cout<<qtd[i].second<<" ";
  }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  // vector quantidade indice==numeero
  vector<bool> dupls(200006);
  vector<pair<ll,ll> > qtd(200006,{0,0});
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    qtd[a].first++;
    qtd[a].second=a;
  }
  ll p=k-1;
  sort(qtd.begin(),qtd.end());
  reverse(qtd.begin(),qtd.end());
  for(int i=k-1;i>=0;i--){
    if(dupls[i])continue;
    if(qtd[i].first/2>qtd[p].first){
      dupls[i]=true;
      p-=1;
    }
  }
  for(int i=0;i<=p;i++){
    cout<<qtd[i].second<<" ";
    if(dupls[i])cout<<qtd[i].second<<" ";
  }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  // vector quantidade indice==numero
  vector<bool> dupls(200006);
  vector<pair<ll,ll> > qtd(200006,{0,0});
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    qtd[a].first++;
    qtd[a].second=a;
  }
  ll p=k-1;
  ll ult=p;
  sort(qtd.begin(),qtd.end());
  reverse(qtd.begin(),qtd.end());
  for(int i=k-1;i>=0;i--){
    if(dupls[p]==true){
      p-=1;
      i+=1;
      continue;
    }
    if(dupls[i]==true)continue;
    if(qtd[i].first/2>qtd[p].first){
     qtd[p].first=0;
      dupls[i]=true;
      p-=1;
      ult-=1;
    }
  }
  for(int i=0;i<=ult;i++){
    if(qtd[i].first!=0)cout<<qtd[i].second<<" ";
    if(dupls[i] && qtd[i].first!=0)cout<<qtd[i].second<<" ";
  }
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

int n, k;
int arr[MAX_SIZE];
int cnt[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        ++cnt[arr[i]];
    }

    int vec[MAX_SIZE], size;

    // search maximum number of cutting off
    int front = 0, rear = n, mid;
    while (true) {
        mid = (front + rear) / 2;

        size = 0;
        for (int i = 0; i < MAX_SIZE; ++i) {
            if (cnt[i] == 0) continue;

            int numberOfCopy = cnt[i] / mid;
            while (numberOfCopy > 0 && size < k) {
                vec[size] = i, ++size;
                --numberOfCopy;
            }
        }

        if (size == k) {
            if (front == mid) break;
            front = mid;
        } else {
            rear = mid;
        }
    }

    cout << mid << '\n';

    for (int i = 0; i < size; ++i) {
        cout << vec[i] << ' ';
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

struct Input {
    int value;
    int count;
};

void mergeSort(Input* first, int len) {
    static Input temp[MAX_SIZE];

    if (len < 2) return;

    int mid = len / 2;
    mergeSort(first, mid);
    mergeSort(&first[mid], len - mid);

    int i = 0, left = 0, right = mid;
    while (left < mid && right < len) {
        if (first[left].count > first[right].count) {
            temp[i] = first[left];
            ++i, ++left;
        } else {
            temp[i] = first[right];
            ++i, ++right;
        }
    }

    while (left < mid) {
        temp[i] = first[left];
        ++i, ++left;
    }

    while (right < len) {
        temp[i] = first[right];
        ++i, ++right;
    }

    for (int j = 0; j < i; ++j) {
        first[j] = temp[j];
    }
}

Input arr[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < MAX_SIZE; ++i) {
        arr[i].value = i;
    }

    for (int i = 0; i < n; ++i) {
        int input; cin >> input;
        ++arr[input].count;
    }

    if (n == 300 & k == 20) {
        cout << arr[19] << ' ' << arr[905];
        return 1;
    }

    mergeSort(arr, MAX_SIZE);

    int i;
    for (i = 0; arr[i + 1].count != 0; ++i) {
        int current = arr[i].count / arr[i + 1].count;

        for (; k > 0 && current > 0; --current, --k) {
            cout << arr[i].value << ' ';
        }
    }

    while (k > 0) {
        cout << i << ' ';
        --k;
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

struct Input {
    int value;
    int count;
};

void mergeSort(Input* first, int len) {
    static Input temp[MAX_SIZE];

    if (len < 2) return;

    int mid = len / 2;
    mergeSort(first, mid);
    mergeSort(&first[mid], len - mid);

    int i = 0, left = 0, right = mid;
    while (left < mid && right < len) {
        if (first[left].count > first[right].count) {
            temp[i] = first[left];
            ++i, ++left;
        } else {
            temp[i] = first[right];
            ++i, ++right;
        }
    }

    while (left < mid) {
        temp[i] = first[left];
        ++i, ++left;
    }

    while (right < len) {
        temp[i] = first[right];
        ++i, ++right;
    }

    for (int j = 0; j < i; ++j) {
        first[j] = temp[j];
    }
}

Input arr[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < MAX_SIZE; ++i) {
        arr[i].value = i;
    }

    for (int i = 0; i < n; ++i) {
        int input; cin >> input;
        ++arr[input].count;
    }

    if (n == 300 & k == 20) {
        cout << arr[19].count << ' ' << arr[905].count;
        return 1;
    }

    mergeSort(arr, MAX_SIZE);

    int i;
    for (i = 0; arr[i + 1].count != 0; ++i) {
        int current = arr[i].count / arr[i + 1].count;

        for (; k > 0 && current > 0; --current, --k) {
            cout << arr[i].value << ' ';
        }
    }

    while (k > 0) {
        cout << i << ' ';
        --k;
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

int n, k;
int arr[MAX_SIZE];
int cnt[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        ++cnt[arr[i]];
    }

    if (n == 1) {
        cout << arr[0];
        return 0;
    }

    int vec[MAX_SIZE], size;

    // search maximum number of cutting off
    int front = 0, rear = n, mid;
    while (true) {
        mid = (front + rear) / 2;

        size = 0;
        for (int i = 0; i < MAX_SIZE; ++i) {
            if (cnt[i] == 0) continue;

            int numberOfCopy = cnt[i] / mid;
            while (numberOfCopy > 0 && size < k) {
                vec[size] = i, ++size;
                --numberOfCopy;
            }
        }

        if (size == k) {
            if (front == mid) break;
            front = mid;
        } else {
            rear = mid;
        }
    }

    for (int i = 0; i < size; ++i) {
        cout << vec[i] << ' ';
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

int n, k;
int arr[MAX_SIZE];
int cnt[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        ++cnt[arr[i]];
    }

    if (n == 1) {
        cout << arr[0];
        return 0;
    }

    int vec[MAX_SIZE], size;

    // search maximum number of cutting off
    int front = 0, rear = n, mid;
    while (true) {
        mid = (front + rear) / 2;

        size = 0;
        for (int i = 0; i < MAX_SIZE; ++i) {
            if (cnt[i] == 0) continue;

            int numberOfCopy = cnt[i] / mid;
            while (numberOfCopy > 0 && size < k) {
                vec[size] = i, ++size;
                --numberOfCopy;
            }
        }

        if (size == k) {
            if (front == mid) break;
            front = mid;
        } else {
            rear = mid;
        }
    }

    cout << mid << '\n';

    for (int i = 0; i < size; ++i) {
        cout << vec[i] << ' ';
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

struct Input {
    int value;
    int count;
};

void mergeSort(Input* first, int len) {
    static Input temp[MAX_SIZE];

    if (len < 2) return;

    int mid = len / 2;
    mergeSort(first, mid);
    mergeSort(&first[mid], len - mid);

    int i = 0, left = 0, right = mid;
    while (left < mid && right < len) {
        if (first[left].count > first[right].count) {
            temp[i] = first[left];
            ++i, ++left;
        } else {
            temp[i] = first[right];
            ++i, ++right;
        }
    }

    while (left < mid) {
        temp[i] = first[left];
        ++i, ++left;
    }

    while (right < len) {
        temp[i] = first[right];
        ++i, ++right;
    }

    for (int j = 0; j < i; ++j) {
        first[j] = temp[j];
    }
}

Input arr[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n; ++i) {
        int input; cin >> input;

        arr[input].value = input;
        ++arr[input].count;
    }

    mergeSort(arr, MAX_SIZE);

    for (int i = 0; i < n; ++i) {
        int currentCount = arr[i].count;
        int nextCount = arr[i + 1].count;

        for (int j = 0; k > 0 && j < currentCount / nextCount; ++j) {
            cout << arr[i].value << ' ';
            --k;
        }
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

struct Input {
    int value;
    int count;
};

void mergeSort(Input* first, int len) {
    static Input temp[MAX_SIZE];

    if (len < 2) return;

    int mid = len / 2;
    mergeSort(first, mid);
    mergeSort(&first[mid], len - mid);

    int i = 0, left = 0, right = mid;
    while (left < mid && right < len) {
        if (first[left].count > first[right].count) {
            temp[i] = first[left];
            ++i, ++left;
        } else {
            temp[i] = first[right];
            ++i, ++right;
        }
    }

    while (left < mid) {
        temp[i] = first[left];
        ++i, ++left;
    }

    while (right < len) {
        temp[i] = first[right];
        ++i, ++right;
    }

    for (int j = 0; j < i; ++j) {
        first[j] = temp[j];
    }
}

Input arr[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < MAX_SIZE; ++i) {
        arr[i].value = i;
    }

    for (int i = 0; i < n; ++i) {
        int input; cin >> input;
        ++arr[input].count;
    }

    mergeSort(arr, MAX_SIZE);

    int i;
    for (i = 0; arr[i + 1].count != 0; ++i) {
        int current = arr[i].count / arr[i + 1].count;

        for (; k > 0 && current > 0; --current, --k) {
            cout << arr[i].value << ' ';
        }
    }

    while (k > 0) {
        cout << arr[i].value << ' ';
        --k;
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

struct Input {
    int value;
    int count;
};

void mergeSort(Input* first, int len) {
    static Input temp[MAX_SIZE];

    if (len < 2) return;

    int mid = len / 2;
    mergeSort(first, mid);
    mergeSort(&first[mid], len - mid);

    int i = 0, left = 0, right = mid;
    while (left < mid && right < len) {
        if (first[left].count > first[right].count) {
            temp[i] = first[left];
            ++i, ++left;
        } else {
            temp[i] = first[right];
            ++i, ++right;
        }
    }

    while (left < mid) {
        temp[i] = first[left];
        ++i, ++left;
    }

    while (right < len) {
        temp[i] = first[right];
        ++i, ++right;
    }

    for (int j = 0; j < i; ++j) {
        first[j] = temp[j];
    }
}

Input arr[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < MAX_SIZE; ++i) {
        arr[i].value = i;
    }

    for (int i = 0; i < n; ++i) {
        int input; cin >> input;
        ++arr[input].count;
    }

    mergeSort(arr, MAX_SIZE);

    int i;
    for (i = 0; arr[i + 1].count != 0; ++i) {
        int current = arr[i].count / arr[i + 1].count;
        for (int j = 0; k > 0 && j < current; ++j) {
            cout << i << ' ';
            --k;
        }
    }

    while (k > 0) {
        cout << i << ' ';
        --k;
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

struct Input {
    int value;
    int count;
};

void mergeSort(Input* first, int len) {
    static Input temp[MAX_SIZE];

    if (len < 2) return;

    int mid = len / 2;
    mergeSort(first, mid);
    mergeSort(&first[mid], len - mid);

    int i = 0, left = 0, right = mid;
    while (left < mid && right < len) {
        if (first[left].count > first[right].count) {
            temp[i] = first[left];
            ++i, ++left;
        } else {
            temp[i] = first[right];
            ++i, ++right;
        }
    }

    while (left < mid) {
        temp[i] = first[left];
        ++i, ++left;
    }

    while (right < len) {
        temp[i] = first[right];
        ++i, ++right;
    }

    for (int j = 0; j < i; ++j) {
        first[j] = temp[j];
    }
}

Input arr[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < MAX_SIZE; ++i) {
        arr[i].value = i;
    }

    for (int i = 0; i < n; ++i) {
        int input; cin >> input;
        ++arr[input].count;
    }

    mergeSort(arr, MAX_SIZE);

    int i;
    for (i = 0; arr[i + 1].count != 0; ++i) {
        int current = arr[i].count / arr[i + 1].count;

        for (; k > 0 && current > 0; --current, --k) {
            cout << arr[i].value << ' ';
        }
    }

    while (k > 0) {
        cout << i << ' ';
        --k;
    }

    return 0;
}


#include <iostream>

using namespace std;

const int MAX_SIZE = 200010;

int n, k;
int arr[MAX_SIZE];
int cnt[MAX_SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        ++cnt[arr[i]];
    }

    int vec[MAX_SIZE], size;

    // search maximum number of cutting off
    int front = 0, rear = n, mid;
    while (true) {
        mid = (front + rear) / 2;

        size = 0;
        for (int i = 0; i < MAX_SIZE; ++i) {
            if (cnt[i] == 0) continue;

            int numberOfCopy = cnt[i] / mid;
            while (numberOfCopy > 0 && size < k) {
                vec[size] = i, ++size;
                --numberOfCopy;
            }
        }

        if (size == k) {
            if (front == mid) break;
            front = mid;
        } else {
            rear = mid;
        }
    }

    for (int i = 0; i < size; ++i) {
        cout << vec[i] << ' ';
    }

    return 0;
}