You are given an array $s$ consisting of $n$ integers.

You have to find any array $t$ of length $k$ such that you can cut out maximum number of copies of array $t$ from array $s$.

Cutting out the copy of $t$ means that for each element $t_i$ of array $t$ you have to find $t_i$ in $s$ and remove it from $s$. If for some $t_i$ you cannot find such element in $s$, then you cannot cut out one more copy of $t$. The both arrays can contain duplicate elements.

For example, if $s = [1, 2, 3, 2, 4, 3, 1]$ and $k = 3$ then one of the possible answers is $t = [1, 2, 3]$. This array $t$ can be cut out $2$ times.   To cut out the first copy of $t$ you can use the elements $[1, \underline{\textbf{2}}, 3, 2, 4, \underline{\textbf{3}}, \underline{\textbf{1}}]$ (use the highlighted elements). After cutting out the first copy of $t$ the array $s$ can look like $[1, 3, 2, 4]$.  To cut out the second copy of $t$ you can use the elements $[\underline{\textbf{1}}, \underline{\textbf{3}}, \underline{\textbf{2}}, 4]$. After cutting out the second copy of $t$ the array $s$ will be $[4]$. 

Your task is to find such array $t$ that you can cut out the copy of $t$ from $s$ maximum number of times. If there are multiple answers, you may choose any of them.


-----Input-----

The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in $s$ and the desired number of elements in $t$, respectively.

The second line of the input contains exactly $n$ integers $s_1, s_2, \dots, s_n$ ($1 \le s_i \le 2 \cdot 10^5$).


-----Output-----

Print $k$ integers — the elements of array $t$ such that you can cut out maximum possible number of copies of this array from $s$. If there are multiple answers, print any of them. The required array $t$ can contain duplicate elements. All the elements of $t$ ($t_1, t_2, \dots, t_k$) should satisfy the following condition: $1 \le t_i \le 2 \cdot 10^5$.


-----Examples-----
Input
7 3
1 2 3 2 4 3 1

Output
1 2 3 

Input
10 4
1 3 1 3 10 3 7 7 12 3

Output
7 3 1 3

Input
15 2
1 2 1 1 1 2 1 1 2 1 2 1 1 1 1

Output
1 1 



-----Note-----

The first example is described in the problem statement.

In the second example the only answer is $[7, 3, 1, 3]$ and any its permutations. It can be shown that you cannot choose any other array such that the maximum number of copies you can cut out would be equal to $2$.

In the third example the array $t$ can be cut out $5$ times.

Difficulty: MEDIUM_HARD
Tags: Sorting
Skill types: Sorting

Starter code:

Solutions:
(n, k) = map(int, input().split())
S = list(map(int, input().split()))
g = {}
for i in S:
	if i not in g:
		g[i] = 0
	g[i] += 1
l = 0
r = 10 ** 7
realans = S
while r - l > 1:
	m = (l + r) // 2
	cnt = 0
	ans = []
	for i in g:
		cnt += g[i] // m
		for _ in range(g[i] // m):
			ans.append(i)
	if cnt >= k:
		realans = ans
		l = m
	else:
		r = m
print(' '.join(list(map(str, realans[:k]))))


(n, k) = map(int, input().split(' '))
s = list(map(int, input().split(' ')))
den_map = {}
for si in s:
	den_map[si] = den_map[si] + 1 if si in den_map else 1
nums = list(den_map.keys())
nums.sort(key=lambda num: den_map[num], reverse=True)
fst = 0
lst = 200001
tl = 0
while fst < lst:
	mdl = (fst + lst) // 2
	can = False
	kn = 0
	for num in nums:
		kn += den_map[num] // mdl
		if kn >= k:
			can = True
			tl = max(tl, mdl)
			break
	if can:
		fst = mdl + 1
	else:
		lst = mdl
t = []
for num in nums:
	count = min(k, den_map[num] // tl)
	t.extend([num] * count)
	k -= count
	if k == 0:
		break
print(*t)


from sys import *
(n, k) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
s = list(set(arr))
a = []
d = {}
for i in range(len(arr)):
	if arr[i] in d:
		d[arr[i]] += 1
	else:
		d[arr[i]] = 1
for i in d:
	a.append([i, d[i]])
a.sort(key=lambda x: x[1])
a.reverse()
l = 1
r = a[0][1]
my_ans = -1
while l <= r:
	mid = (l + r) // 2
	tmp = k
	for i in range(len(a)):
		tmp -= a[i][1] // mid
		if tmp <= 0:
			my_ans = mid
			break
	if tmp <= 0:
		l = mid + 1
	else:
		r = mid - 1
if n == k:
	print(*arr)
else:
	ans = []
	length = 0
	for i in range(len(a)):
		for j in range(a[i][1] // my_ans):
			ans.append(a[i][0])
			length += 1
			if length == k:
				break
		if length == k:
			break
	print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import heapq
from collections import Counter
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
c = Counter(arr)
ls = []
for i in c:
	for j in range(1, c[i] + 1):
		ls.append((i, c[i] // j))
ls.sort(key=lambda x: x[1], reverse=True)
for i in range(k):
	print(ls[i][0], end=' ')


from collections import Counter
(n, k) = map(int, input().split())
S = list(map(int, input().split()))
c = Counter(S)
l = [(i, c[i]) for i in list(c)]
l_ = []
for (l, m) in l:
	j = 1
	while m // j != 0:
		l_.append((l, m // j))
		j += 1
l_.sort(key=lambda x: x[1], reverse=True)
for i in range(k):
	print(l_[i][0], end=' ')


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
di = {}
for i in arr:
	try:
		di[i] += 1
	except:
		di[i] = 1
d = []
for i in di:
	d.append((i, di[i]))
res = []

def can(x):
	global res
	res = []
	for i in d:
		kol = min(i[1] // x, k - len(res))
		for j in range(kol):
			res.append(i[0])
	return len(res) == k
l = 0
r = n
while r - l > 1:
	m = (l + r) // 2
	if can(m):
		l = m
	else:
		r = m
if not can(r):
	can(l)
print(*res)


import sys
input = sys.stdin.readline
from collections import Counter as cc
I = lambda : list(map(int, input().split()))
(n, k) = I()
l = I()
t = []
x = cc(l)
d = sorted([[x[i], i] for i in set(l)], reverse=True)
l = 1
r = n
while l < r:
	md = (l + r + 1) // 2
	te = 0
	for i in d:
		te += i[0] // md
	if te >= k:
		l = md
	else:
		r = md - 1
for i in d:
	for j in range(i[0] // l):
		if len(t) < k:
			t.append(i[1])
print(*t)


import sys

def rint():
	return map(int, sys.stdin.readline().split())

def can(v):
	s = 0
	for i in d:
		s += d[i] // v
	if s >= k:
		return True
	else:
		return False
(n, k) = rint()
s = list(rint())
d = dict()
for i in range(n):
	if not s[i] in d:
		d[s[i]] = 1
	else:
		d[s[i]] += 1
l = 0
r = n
while r - l > 1:
	mid = (l + r) // 2
	if can(mid):
		l = mid
	else:
		r = mid
if can(r):
	v = r
else:
	v = l
ans = []
cnt = 0
for i in d:
	a = d[i] // v
	if cnt == k:
		break
	for _ in range(a):
		ans.append(i)
		cnt += 1
		if cnt == k:
			break
print(*ans)


(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
d = {}
for i in a:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
s = []
for (i, j) in d.items():
	s.append([j, i])
s.sort(reverse=True)
b = []
for i in range(len(s)):
	j = 1
	while s[i][0] // j != 0:
		b.append([s[i][0] // j, s[i][1]])
		j += 1
b.sort(reverse=True)
for i in range(k):
	print(b[i][1], end=' ')


import sys
import math
from collections import *
from queue import *
from bisect import *
MOD = int(1000000000.0 + 7)
inf = float('inf')
ninf = float('-inf')
input = sys.stdin.readline

def ii():
	return list(map(int, input().strip().split()))
(n, k) = ii()
arr = ii()
d = defaultdict(int)
for k1 in arr:
	d[k1] += 1
res = []
for (i, j) in d.items():
	for p in range(1, j + 1):
		res.append([j // p, i])
res.sort(reverse=True)
print(' '.join((str(b) for (a, b) in res[:k])))


import sys
import math
from collections import defaultdict, deque

def is_possible(m, dic, k):
	s = 0
	for i in dic:
		s += dic[i] // m
	if s >= k:
		return True
	return False
(n, m) = map(int, sys.stdin.readline().split())
dic = defaultdict(int)
arr = list(map(int, sys.stdin.readline().split()))
for i in range(n):
	dic[arr[i]] += 1
l = []
for i in dic:
	l.append([dic[i], i])
(low, high) = (1, n)
ans = 1
while low <= high:
	mid = (low + high) // 2
	if is_possible(mid, dic, m):
		low = mid + 1
		ans = mid
	else:
		high = mid - 1
l = []
c = 0
nax = ans
for i in dic:
	x = dic[i] // nax
	cnt = 0
	while c < m and cnt < x:
		l.append(i)
		c += 1
		cnt += 1
	if c == m:
		break
print(*l)


def main():
	from collections import Counter
	(N, K) = (int(i) for i in input().split())
	A = [int(i) for i in input().split()]

	def is_ok(i):
		ok = 0
		cnt = Counter()
		for a in A:
			cnt[a] += 1
			if cnt[a] == i:
				cnt[a] = 0
				ok += 1
		if K <= ok:
			return True
		else:
			return False

	def binary_search():
		ng = 2 * 10 ** 5
		ok = 1
		while abs(ok - ng) > 1:
			mid = ng + (ok - ng) // 2
			if is_ok(mid):
				ok = mid
			else:
				ng = mid
		return ok
	i = binary_search()
	ans = []
	cnt = Counter()
	for a in A:
		cnt[a] += 1
		if cnt[a] == i and len(ans) < K:
			cnt[a] = 0
			ans.append(a)
	print(*ans)
main()


from collections import Counter

def can_cut(t, nm, k):
	total = 0
	for (cnt, num) in t:
		if cnt // nm == 0:
			return False
		total += cnt // nm
		if total >= k:
			return True
(n, k) = map(int, input().split())
s = list(map(int, input().split()))
c = Counter(s)
t = [(b, a) for (a, b) in c.items()]
t.sort(reverse=True)
(l, r) = (0, t[0][0] + 1)
while l + 1 != r:
	m = (l + r) // 2
	if not can_cut(t, m, k):
		r = m
	else:
		l = m
arr = []
for p in t:
	arr.extend([str(p[1])] * (p[0] // l))
print(' '.join(arr[:k]))


import collections
(N, K) = map(int, input().split())
S = [int(x) for x in input().split()]
wc = [(c, w) for (w, c) in collections.Counter(S).items()]
wc.sort(reverse=True)
(lo, hi) = (1, wc[0][0])
while lo <= hi:
	md = (lo + hi) // 2
	count = 0
	for (c, w) in wc:
		if c < md:
			break
		else:
			count += c // md
		if count >= K:
			break
	if count >= K:
		lo = md + 1
	else:
		hi = md - 1
lo -= 1
ans = []
for (c, w) in wc:
	if c < lo:
		break
	else:
		ans.extend([w] * (c // lo))
	if len(ans) >= K:
		break
print(' '.join(map(str, ans[:K])))


def check(d, h):
	temp = 0
	for i in d.values():
		temp += i // mid
		if temp >= k:
			return True
	return False
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
l = 1
r = n
ans = 0
while l <= r:
	mid = (l + r) // 2
	if check(d, mid):
		ans = max(ans, mid)
		l = mid + 1
	else:
		r = mid - 1
a = []
tem = 0
for i in d.keys():
	for _ in range(d[i] // ans):
		if tem < k:
			a.append(i)
			tem += 1
print(*a)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
K = 2 * 10 ** 5
b = [0] * K
for aa in a:
	b[aa - 1] += 1
c = []
for i in range(K):
	if b[i] != 0:
		c.append((b[i], i + 1))
c.sort(reverse=True)
(left, right) = (1, n // k + 1)
while left != right - 1:
	(mid, cnt) = ((left + right) // 2, 0)
	for x in c:
		cnt += x[0] // mid
		if cnt >= k:
			break
	if cnt >= k:
		left = mid
	else:
		right = mid
ans = []
for x in c:
	if len(ans) == k:
		break
	for i in range(x[0] // left):
		ans.append(x[1])
		if len(ans) == k:
			break
print(*ans)


(n, k) = list(map(int, input().split()))
s = list(map(int, input().split()))
c = [0 for i in range(200000 + 1)]
for i in s:
	c[i - 1] += 1
p = list(range(200000))
p.sort(key=lambda x: c[x], reverse=True)
ans = 0
res = []
for i in range(k):
	res.append(s[i])

def check(t):
	v = []
	global res
	for i in p:
		cnt = c[i] // t
		for j in range(cnt):
			if len(v) == k:
				break
			v.append(i)
		if len(v) == k:
			break
	if len(v) == k:
		res = v
		return True
	else:
		return False
for d in range(20, -1, -1):
	if (ans + (1 << d)) * k > n:
		continue
	if check(ans + (1 << d)):
		ans += 1 << d
for i in res:
	print(i + 1, end=' ')


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
from collections import Counter
c = Counter(l)
elems = []
freq = []
z = c.most_common(k)
for i in z:
	elems.append(i[0])
	freq.append(i[1])

def bs(mid):
	ans = 0
	for i in freq:
		if i >= mid:
			ans += i // mid
	return ans >= k
lo = 1
hi = 10 ** 10
while lo <= hi:
	mid = (lo + hi) // 2
	if bs(mid):
		lo = mid + 1
		ans = mid
	else:
		hi = mid - 1
cnt = 0
res = []
for i in range(len(elems)):
	if cnt == k:
		break
	if freq[i] >= ans:
		curr = freq[i] // ans
		if cnt + curr <= k:
			cnt += curr
			res.extend([elems[i]] * curr)
		else:
			rem = k - cnt
			res.extend([elems[i]] * rem)
			break
print(*res)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
m = {}
for i in s:
	if i not in m:
		m[i] = 0
	m[i] += 1
m = [[m[i], i] for i in m]
m.sort(reverse=True)

def p(x):
	j = 0
	i = 0
	while i < len(m) and j < k:
		j += m[i][0] // x
		i += 1
	return j >= k
(l, r) = (1, n // k)
while l < r:
	t = (l + r + 1) // 2
	if p(t):
		l = t
	else:
		r = t - 1
o = []
for i in m:
	o += [str(i[1])] * (i[0] // l)
print(' '.join(o[:k]))


from collections import Counter
from heapq import heappop, heappush
ints = lambda line: [int(x) for x in line.split()]
(n, k) = ints(input())
(counter, heap) = (Counter(ints(input())), [])
for (value, count) in counter.most_common(k):
	i = 1
	while count // i > 0:
		heappush(heap, (-(count // i), value))
		i += 1
print(' '.join((str(heappop(heap)[1]) for i in range(k))))


(n, k) = [*map(int, input().split())]
numbers = [*map(int, input().split())]
counter = [0 for x in range(200005)]
for val in numbers:
	counter[val] += 1
licznik = []
for index in range(200001):
	if counter[index] != 0:
		licznik.append((index, counter[index]))
licznik = sorted(licznik, key=lambda licz: -licz[1])

def binar(start, end):
	if start == end:
		return check(start)
	mid = (start + end) // 2 + 1
	odp = check(mid)
	if len(odp) != 0:
		return binar(mid, end)
	else:
		return binar(start, mid - 1)

def check(val):
	ans = []
	licz = 0
	for val_ in licznik:
		liczba = val_[0]
		ilosc = val_[1]
		while ilosc >= val and licz != k:
			ilosc -= val
			ans.append(liczba)
			licz += 1
	if len(ans) != k:
		return []
	else:
		return ans
for val in binar(0, n - 1):
	print(val)


from collections import *
R = lambda : map(int, input().split())
(n, k) = R()
r = []
for (l, m) in Counter(R()).items():
	r += ((m // i, l) for i in range(1, m + 1))
print(*(x for (_, x) in sorted(r)[-k:]))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
tp = []
for i in l:
	if i not in d:
		d[i] = 0
	d[i] += 1
for i in d:
	tp.append([d[i], i])
tp.sort(reverse=True)
ans = []
for i in range(len(tp)):
	p = 1
	while tp[i][0] // p != 0:
		ans.append([tp[i][0] // p, tp[i][1]])
		p += 1
ans.sort(reverse=True)
for i in range(k):
	print(ans[i][1], end=' ')
print()


(n, k) = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
counter = {}
for item in s:
	if item not in counter:
		counter[item] = 1
	else:
		counter[item] += 1
total_counter = []
for item in counter:
	total_counter.append((counter[item], item))
total_counter.sort(reverse=True)
what = []
left = 0
right = n + 1
answer = []
lena = len(total_counter)
while right - left > 1:
	kpob = k
	maybe = 0
	what = []
	middle = (left + right) // 2
	for item in range(min(k, lena)):
		maybe += total_counter[item][0] // middle
		if maybe >= k:
			left = middle
			break
	else:
		right = middle
what = []
kpob = k
for item in range(min(k, lena)):
	maybe += total_counter[item][0] // left
	for i in range(min(total_counter[item][0] // left, kpob)):
		what.append(total_counter[item][1])
		kpob -= 1
print(*what)


def case(mid):
	(elems, length) = ([], 0)
	for (i, x) in enumerate(d):
		item = d[x] // mid
		length += item
	return length
(n, k) = map(int, input().split())
lst = [*map(int, input().split())]
d = {}
for (i, x) in enumerate(lst):
	if d.get(x) == None:
		d[x] = 0
	d[x] += 1
(i, j) = (1, n)
while i + 1 < j:
	mid = (i + j) // 2
	leng = case(mid)
	if leng >= k:
		i = mid
	else:
		j = mid
if case(j) >= k:
	res = j
else:
	res = i
result = []
ex = result.extend
for (i, x) in enumerate(d):
	ex([x] * (d[x] // res))
print(*result[:k])


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
(n, k) = mapi()
a = list(mapi())
res = []
mp = defaultdict(int)
for i in a:
	mp[i] += 1
l = 0
r = n + 1
copies = 0

def check(mid):
	tmp = 0
	for v in mp.values():
		tmp += v // mid
	return tmp >= k
while r - l > 0:
	mid = l + r >> 1
	if check(mid):
		copies = mid
		l = mid + 1
	else:
		r = mid
if check(l):
	copies = l
elif check(r):
	copies = r
for (i, v) in mp.items():
	for j in range(v // copies):
		res.append(i)
print(*res[:k])


(n, k) = map(int, input().split())
S = list(map(int, input().split()))
from collections import Counter
C = Counter(S)

def is_ok(x):
	if x == 0:
		return True
	cnt = 0
	for (key, v) in C.items():
		cnt += v // x
	if cnt >= k:
		return True
	else:
		return False
ok = 0
ng = 10 ** 18
while ok + 1 < ng:
	c = (ok + ng) // 2
	if is_ok(c):
		ok = c
	else:
		ng = c
ans = []
for (key, v) in C.items():
	ans += [key] * (v // ok)
print(*ans[0:k])


from __future__ import print_function
from collections import *
from sys import stdin
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(n, k) = gil()
f = Counter(gil())
(l, r) = (2, n // k)
ans = 1

def isPos(x):
	cnt = 0
	for v in f:
		cnt += f[v] // x
	return cnt >= k
while l <= r:
	mid = (l + r) // 2
	if isPos(mid):
		ans = mid
		l = mid + 1
	else:
		r = mid - 1
a = []
cnt = k
for v in f:
	if cnt == 0:
		break
	fi = min(f[v] // ans, cnt)
	cnt -= fi
	if fi:
		a.append((str(v) + ' ') * fi)
print(''.join(a))


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
from collections import Counter
c = Counter(s)
z = dict()

def f(x):
	global n, k, c, z
	if x > n:
		return False
	if x == 0:
		return True
	ret = 0
	z = dict()
	for i in c:
		ret += c[i] // x
		z[i] = c[i] // x
	return ret >= k
(l, r) = (0, 10 ** 6)
while l + 1 < r:
	y = l + (r - l) // 2
	if f(y):
		l = y
	else:
		r = y
f(l)
ans = []
for i in z:
	for j in range(z[i]):
		ans.append(str(i))
print(' '.join(ans[:k]))


from collections import defaultdict
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
m = defaultdict(int)
for i in range(n):
	m[a[i]] += 1
p = []
for i in m:
	for j in range(1, m[i] + 1):
		p.append((i, m[i] / j))
p = sorted(p, key=lambda x: x[1], reverse=True)
res = []
for i in range(k):
	res.append(p[i][0])
print(*res)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(n, k) = int_array()
a = int_array()
c = {}
for i in a:
	c[i] = c.get(i, 0) + 1
aset = set(a)
LIST = [(i, c[i]) for i in aset]
NLIST = []
for (l, m) in LIST:
	j = 1
	while m // j != 0:
		NLIST.append((l, m // j))
		j += 1
NLIST.sort(key=lambda x: x[1], reverse=True)
ans = [NLIST[i][0] for i in range(k)]
print(*ans)


from heapq import heappop, heappush
(n, k) = map(int, input().split())
w = {}
for i in [int(i) for i in input().split()]:
	w[i] = w.get(i, 0) + 1
heap = []
for i in sorted(w.items(), key=lambda x: -x[1]):
	heappush(heap, [-i[1], i[0], 1])
ans = []
for i in range(k):
	tmp_ans = heappop(heap)
	ans.append(tmp_ans[1])
	heappush(heap, [-(abs(w[tmp_ans[1]]) // (tmp_ans[2] + 1)), tmp_ans[1], tmp_ans[2] + 1])
print(*ans)


import sys
input = sys.stdin.readline

def f(z):
	ans = 0
	for i in l:
		ans += i[0] // z
	if ans >= k:
		return 1
	return 0

def bsearch(l, r):
	m = (l + r) // 2
	if f(m):
		if f(m + 1) == 0:
			return m
		return bsearch(m + 1, r)
	return bsearch(l, m - 1)
l = input().split()
n = int(l[0])
k = int(l[1])
l = input().split()
li = [int(i) for i in l]
hashi = dict()
for i in li:
	if i not in hashi:
		hashi[i] = 0
	hashi[i] += 1
l = []
ok = []
for i in hashi:
	l.append((hashi[i], i))
l.sort()
l.reverse()
z = bsearch(1, 10 ** 9)
rem = k
for i in range(len(l)):
	maxa = l[i][0] // z
	if rem > maxa:
		for k in range(maxa):
			print(l[i][1], end=' ')
		rem -= maxa
	else:
		for j in range(rem):
			print(l[i][1], end=' ')
		break


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
N = 202020
cnt = [0] * N
b = []

def ok(m):
	need = k
	b.clear()
	for i in range(N):
		t = min(need, cnt[i] // m)
		need -= t
		for j in range(t):
			b.append(i)
		if need == 0:
			return 1
	return 0
for i in a:
	cnt[i] += 1
l = 1
r = n // k
cur = 0
while l <= r:
	m = (l + r) // 2
	if ok(m):
		cur = m
		l = m + 1
	else:
		r = m - 1
ok(cur)
for i in range(k):
	print(b[i], end=' ')


p_line = [int(x) for x in input().strip().split(' ')]
size = p_line[0]
req_len = p_line[1]
a = [int(x) for x in input().strip().split(' ')]
num_to_occ = {}
for x in a:
	if x not in num_to_occ:
		num_to_occ[x] = 0
	num_to_occ[x] += 1
num_occ_list = sorted([(x, y) for (x, y) in num_to_occ.items()], key=lambda x: x[1], reverse=True)
begin = 1
end = len(a) + 1

def IsPossible(x):
	counter = req_len
	for z in num_occ_list:
		num_time = int(z[1] / x)
		counter -= num_time
		if counter <= 0:
			break
	return counter <= 0
while end > begin + 1:
	mid = int((begin + end) / 2)
	if IsPossible(mid):
		begin = mid
	else:
		end = mid
result_list = []
for z in num_occ_list:
	num_time = int(z[1] / begin)
	while num_time > 0 and len(result_list) < req_len:
		result_list.append(z[0])
		num_time -= 1
for x in result_list:
	print(x, end=' ')


[n, k] = [int(x) for x in input().split(' ')]
s = list(sorted([int(x) for x in input().split(' ')]))
table = []
for i in range(n):
	if i == 0:
		table.append([s[i], 1])
	elif s[i] == s[i - 1]:
		table[len(table) - 1][1] += 1
	else:
		table.append([s[i], 1])

def can(length):
	totalLength = 0
	for x in table:
		totalLength += x[1] // length
	return totalLength >= k
lower = 1
upper = n
mid = (upper + lower) // 2
while lower < upper and mid != lower and (mid != upper):
	if can(mid):
		lower = mid
	else:
		upper = mid
	mid = (upper + lower) // 2
result = []
for x in table:
	if x[1] >= mid:
		for _ in range(x[1] // mid):
			result.append(x[0])
result = result[:k]
print(' '.join([str(x) for x in result]))


(n, k) = map(int, input().split())
a = list(map(int, input().strip().split()))
alla = [0] * 200005
for x in a:
	alla[x] += 1
als = set(a)
res = []
for x in als:
	res.append([alla[x], x])
res.sort()
res.reverse()

def can(d):
	cur = 0
	for x in res:
		cur += x[0] // d
	return cur >= k

def printcan(d):
	cur = 0
	for x in res:
		for i in range(x[0] // d):
			print(x[1], end=' ')
			cur += 1
			if cur == k:
				return
ans = 0
l = 1
r = n
while l < r:
	m = (l + r + 1) // 2
	if can(m):
		l = m
	else:
		r = m - 1
printcan(l)


def is_check(x):
	add = 0
	for i in range(l):
		add = add + b[i][0] // x
	return add
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
store = [0] * (2 * 10 ** 5 + 1)
for i in range(n):
	store[a[i]] += 1
b = []
for i in range(2 * 10 ** 5 + 1):
	if store[i] > 0:
		b.append([store[i], i])
l = len(b)
b.sort(reverse=True)
i = 1
j = 10 ** 9
while i < j:
	m = (i + j) // 2
	if is_check(m) >= k:
		i = m + 1
	else:
		j = m - 1
if is_check(i) < k:
	i -= 1
j = 0
stack = []
while j < l:
	for m in range(min(k, b[j][0] // i)):
		stack.append(b[j][1])
	k = max(0, k - b[j][0] // i)
	j += 1
print(*stack)


def ell(a, b):
	i = 0
	for j in range(b):
		i += p[j] // a
	if i < k:
		return False
	else:
		return True
(n, k) = map(int, input().split())
s = list(map(int, input().split()))
b = max(s)
p = [0 for i in range(b)]
q = []
for i in range(n):
	p[s[i] - 1] += 1
l = 1
r = n
while r > l + 1:
	a = (l + r) // 2
	if ell(a, b) == True:
		l = a
	else:
		r = a
for i in range(b):
	for j in range(p[i] // l):
		q.append(i)
	if len(q) >= k:
		break
for i in range(0, k):
	print(q[i] + 1, end=' ')


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
t = []

def can_execute_once(n):
	global t
	t = []
	count = 0
	for dd in d:
		can_execute_here = min(k - len(t), dd[1] // n)
		t += [dd[0]] * can_execute_here
		count += can_execute_here
	return count >= k
d = {}
for ss in s:
	if ss in d:
		d[ss] += 1
	else:
		d[ss] = 1
d = [[key, value] for (key, value) in d.items()]
d.sort(key=lambda x: -x[1])
l = 0
r = n
while r - l - 1 > 0:
	m = (l + r) // 2
	if can_execute_once(m):
		l = m
	else:
		r = m
flag = can_execute_once(r)
if not flag:
	can_execute_once(l)
print(*t, sep=' ')


from sys import stdin, stdout
from math import *
from heapq import *

class elem:

	def __init__(self, value, counted):
		self.value = value
		self.count = counted
		self.selected = 0

	def test_Next(self):
		return self.count / (self.selected + 1)

	def take1(self):
		self.selected = self.selected + 1

	def __lt__(self, other):
		return self.test_Next() > other.test_Next()

def main():
	global n, k, a
	(n, k) = [int(x) for x in stdin.readline().split()]
	a = [int(x) for x in stdin.readline().split()]
	if k * 2 > n:
		stdout.write(' '.join([str(x) for x in a[:k]]))
		return 0
	count = dict()
	for x in a:
		count[x] = count.get(x, 0) + 1
	s = []
	for (ky, v) in count.items():
		s.append(elem(ky, v))
	heapify(s)
	res = []
	for i in range(k):
		maxNext = heappop(s)
		maxNext.take1()
		res.append(str(maxNext.value))
		heappush(s, maxNext)
	stdout.write(' '.join(res))
	return 0
main()


def func(num):
	t = 0
	for j in c.values():
		t += j // num
	return t >= k
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
c = {}
for i in range(n):
	c[arr[i]] = c.get(arr[i], 0) + 1
l = 1
r = n
while l < r:
	mid = (l + r + 1) // 2
	if func(mid):
		l = mid
	else:
		r = mid - 1
ans = []
cou = 0
for x in c.keys():
	for i in range(c[x] // r):
		if cou < k:
			ans.append(x)
			cou += 1
print(*ans)


from math import floor

def main():
	(n, k) = (int(x) for x in input().split(' '))
	l = input().split(' ')
	count = {}
	for x in l:
		if x in count:
			count[x] += 1
		else:
			count[x] = 1
	sorted_count = sorted(count.items(), key=lambda kv: -kv[1])[:k]
	x = sorted_count[0][1]
	for x in range(sorted_count[0][1], 0, -1):
		s = 0
		invalid = True
		for y in sorted_count:
			if s > k or y[1] < x:
				break
			s += floor(y[1] / x)
		if s >= k:
			break
	o = []
	while len(o) < k:
		for y in sorted_count:
			if y[1] < x:
				break
			o += [y[0]] * floor(y[1] / x)
	print(' '.join(o[:k]))
main()


from collections import defaultdict
import sys
input = sys.stdin.readline

def binary_search(c1, c2):
	m = (c1 + c2 + 1) // 2
	if abs(c1 - c2) <= 1:
		ans = error_check(m)
		return ans
	else:
		if ok(m):
			c1 = m
		else:
			c2 = m
		return binary_search(c1, c2)

def ok(m):
	cnt = 0
	for i in x:
		cnt += i // m
	return True if cnt >= k else False

def error_check(i):
	for j in range(max(1, i - 3), min(n + 3, i + 4)):
		if not ok(j):
			return j - 1
(n, k) = map(int, input().split())
s = list(map(int, input().split()))
cnt = defaultdict(lambda : 0)
for i in s:
	cnt[i] += 1
(x, y) = ([], [])
for i in cnt:
	x.append(cnt[i])
	y.append(i)
m = binary_search(0, n)
ans = []
for i in range(len(x)):
	for _ in range(x[i] // m):
		ans.append(y[i])
while len(ans) ^ k:
	ans.pop()
print(*ans)


import math

def how(listo, div):
	sumi = 0
	for guy in listo:
		if guy[0] < div:
			break
		sumi += guy[0] // div
	return sumi
(n, k) = map(int, input().split())
counts = [0] * 200000
a = list(map(int, input().split()))
for guy in a:
	counts[guy - 1] += 1
stuff = [(counts[i], i + 1) for i in range(200000)]
stuff.sort(reverse=True)
maxi = n // k
mini = 1
curr = (maxi + mini) // 2
while maxi != mini:
	x = how(stuff, curr)
	if x < k:
		maxi = curr - 1
		curr = (mini + curr) // 2
	elif x >= k:
		mini = curr
		curr = math.ceil((maxi + curr) / 2)
out = ''
i = 0
index = 0
curry = stuff[0][0]
while i < k:
	curry -= curr
	out += str(stuff[index][1])[::-1] + ' '
	if curry < curr:
		index += 1
		curry = stuff[index][0]
	i += 1
print(out[:-1][::-1])


import sys
from math import floor
from itertools import repeat
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
count = {}
maxcount = 0
for i in range(n):
	if a[i] not in count.keys():
		count[a[i]] = 0
	count[a[i]] += 1
	maxcount = max(count[a[i]], maxcount)
flipcount = {}
for key in count.keys():
	if count[key] not in flipcount:
		flipcount[count[key]] = []
	flipcount[count[key]].append(key)
sortedKeys = sorted(flipcount.keys(), reverse=True)
ans = []
for mid in range(maxcount + 1, 0, -1):
	ans = []
	for key in sortedKeys:
		timesToAdd = key // mid
		for x in flipcount[key]:
			ans.extend(repeat(x, timesToAdd))
	if len(ans) >= k:
		break
print(' '.join([str(x) for x in ans[:k]]))


(n, k) = map(int, input().split())
s = map(int, input().split())
d = {}
for i in s:
	d[i] = d.get(i, 0) + 1
dr = {}
for b in range(1, max(d.values()) + 1):
	dr[b] = []
for k1 in d:
	dr[d[k1]].append(k1)
dl = {}
for k3 in dr:
	dl[k3] = len(dr[k3])
dk = sorted(dr.keys())
a = 0
q = 0
ldk = len(dk)
while q < k:
	q = 0
	a += 1
	dka = dk[-a]
	for k4 in dk[-a:]:
		q += k4 // dka * dl[k4]
del dk[:-a]
dka = dk[0]
mi = q - k
pr = []
for k5 in dk:
	pr.extend(dr[k5] * (k5 // dka))
del pr[:mi]
for k6 in pr:
	print(k6, end=' ')


(n, k) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
d = {}
for i in l:
	key = i
	if key in d:
		d[key] += 1
	else:
		d[key] = 1
q = []
for i in d:
	q.append([d[i], i])
q.sort()
q = q[::-1]
p = []
for i in range(len(q)):
	j = 1
	while q[i][0] // j != 0:
		p.append([q[i][0] // j, q[i][1]])
		j += 1
p.sort()
p = p[::-1]
p = p[:k]
p.sort()
for i in range(len(p)):
	print(p[i][1], end=' ')


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def sortingfunc(n):
	global counts
	return counts[n]
counts = 0

def main():
	global counts
	(n, k) = get_tuple()
	li = get_list()
	counts = Counter(li)
	keys = list(counts.keys())
	keys.sort(key=sortingfunc, reverse=True)
	max_possible = sum((counts[keys[i]] for i in range(k) if i < len(keys))) // k + 1
	for i in range(max_possible, 0, -1):
		c = 0
		for ki in keys:
			c += counts[ki] // i
		if c >= k:
			break
	res = []
	for j in keys:
		res += [j] * (counts[j] // i)
		if len(res) > k:
			break
	display_list(res[:k])
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


(n, k) = map(int, input().split())
nums = list(map(int, input().split()))
pares = {}
for n in nums:
	pares[n] = pares.get(n, 0) + 1
li = []
for p in pares:
	li.append((pares[p], p))
li.sort(reverse=True)
ini = 0
fin = 10 ** 6
while fin > ini:
	mid = (fin + ini + 1) // 2
	su = 0
	for e in li:
		po = e[0] // mid
		if po == 0:
			break
		su += po
		if su >= k:
			break
	if su >= k:
		ini = mid
	else:
		fin = mid - 1
res = []
p = 0
for i in range(min(k, len(li))):
	if p == k:
		break
	aa = li[i][0] // ini
	for qq in range(aa):
		if p == k:
			break
		res.append(li[i][1])
		p += 1
print(' '.join(map(str, res)))


def can(mid, k, occ):
	cnt = 0
	for value in occ:
		o = occ[value]
		cnt += o // mid
	return cnt >= k
(n, k) = map(int, input().split())
arr = [int(i) for i in input().split()]
occ = {}
for v in arr:
	if v not in occ:
		occ[v] = 0
	occ[v] += 1
(left, right, ans) = (1, len(arr), [])
while left < right:
	m = (left + right + 1) // 2
	if can(m, k, occ):
		left = m
	else:
		right = m - 1
for value in occ:
	o = occ[value]
	ans.extend(o // right * [value])
print(*ans[:k])


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
occs = dict()
for v in arr:
	if v not in occs:
		occs[v] = 0
	occs[v] += 1
(left, right, ans) = (1, 200000, list())

def canGenerate():
	cnt = 0
	for value in occs:
		occurrences = occs[value]
		cnt += occurrences // mid
	return cnt >= k
while left < right:
	mid = (left + right + 1) // 2
	if canGenerate():
		left = mid
	else:
		right = mid - 1
for value in occs:
	occurrences = occs[value]
	ans.extend(occurrences // right * [value])
print(*ans[:k])


from collections import Counter
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
c = Counter(l)
lc = [(i, c[i]) for i in list(c)]
res = []
for v in lc:
	j = 1
	while v[1] // j != 0:
		res.append((v[0], v[1] // j))
		j += 1
res.sort(key=lambda x: x[1], reverse=True)
for i in range(k):
	if i != k - 1:
		print(res[i][0], end=' ')
	else:
		print(res[i][0])


MAX = 200 * 1000 + 1
(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]
cnts = {}
t = []

def can(cnt):
	del t[:]
	for (key, value) in cnts.items():
		need = min(int(value / cnt), k - len(t))
		for j in range(need):
			t.append(key)
	return len(t) == k
for item in arr:
	if item in cnts:
		cnts[item] += 1
	else:
		cnts[item] = 1
l = 0
r = n
while r - l > 1:
	mid = l + r >> 1
	if can(mid):
		l = mid
	else:
		r = mid
if not can(r):
	can(l)
print(*t)


import math

def bs(a, n, k):
	low = 1
	high = n
	while low < high:
		mid = low + math.ceil((high - low) / 2)
		seq_len = 0
		for w in range(len(a)):
			seq_len += a[w][0] // mid
		if seq_len >= k:
			low = mid
		else:
			high = mid - 1
	return low
[n, k] = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
a = []
s.sort()
prev = -2
ind = -1
for x in range(len(s)):
	if s[x] != prev:
		ind += 1
		a.append([1, s[x]])
	else:
		a[ind][0] += 1
	prev = s[x]
a.sort(reverse=True)
ans = bs(a, n, k)
arr = []
ctr = 0
for e in range(len(a)):
	if ctr == k:
		break
	if a[e][0] // ans + ctr > k:
		for p in range(k - ctr):
			arr.append(a[e][1])
		break
	else:
		for p in range(a[e][0] // ans):
			arr.append(a[e][1])
			ctr += 1
for h in range(len(arr)):
	print(arr[h], end=' ')
print()


def func(mid):
	c = 0
	for i in range(len(d)):
		c += p[i][0] // mid
	return c >= k
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = 0
	d[a[i]] += 1
p = []
for i in d:
	p.append([d[i], i])
p.sort(reverse=True)
l = 1
r = 10 ** 10
ans = 1
while l <= r:
	mid = (l + r) // 2
	if func(mid):
		ans = mid
		l = mid + 1
	else:
		r = mid - 1
z = []
for i in range(len(d)):
	for j in range(p[i][0] // ans):
		z.append(p[i][1])
	if len(z) >= k:
		break
print(*z[:k])


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * 200000
for i in a:
	b[i - 1] += 1
c = []
c1 = 0
for i in range(200000):
	if b[i] > 0:
		c.append([b[i], i + 1])
		c1 += 1
c.sort()
c = c[-k:]
d = c[-1][0]
(l, r) = (max(d // k - 1, 0), n // k)
while r - l > 1:
	m = (r + l) // 2
	e = 0
	for i in c:
		e += i[0] // m
	if e > k:
		l = m
	else:
		r = m
e = 0
for i in c:
	e += i[0] // r
while e < k:
	r -= 1
	e = 0
	for i in c:
		e += i[0] // r
f = []
for i in c:
	f += [i[1]] * min(k, i[0] // r)
	k -= i[0] // r
print(*f)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_max(mn, mx, func):
	ok = mn
	ng = mx
	while ok + 1 < ng:
		mid = (ok + ng) // 2
		if func(mid):
			ok = mid
		else:
			ng = mid
	return ok
(N, K) = MAP()
A = LIST()
C = Counter(A)

def check(m):
	res = 0
	for v in C.values():
		res += v // m
	return res >= K
res = bisearch_max(0, 10 ** 6, check)
ans = []
for (k, v) in C.items():
	if v // res != 0:
		ans += [k] * (v // res)
print(*ans[:K])


from collections import defaultdict
(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
count = defaultdict(int)
for a in arr:
	count[a] += 1

def m_copies(m):
	elements = 0
	for (key, val) in count.items():
		elements += val // m
	return elements >= k
low = 1
high = n
while low < high:
	mid = (low + high) // 2 + 1
	if m_copies(mid):
		low = mid
	else:
		high = mid - 1
best = max(1, high)
ans = []
for (key, val) in count.items():
	p = val // best
	if p > 0:
		ans.extend([key] * p)
	if len(ans) >= k:
		break
ans = ans[:k]
print(' '.join((str(x) for x in ans)))


T = []
N = []
D = []
for i in range(2 * 100000 + 1):
	T.append([])
	N.append(0)
	D.append(1)
t = input().split(' ')
(n, k) = (int(t[0]), int(t[1]))
S = input().split(' ')
for i in range(n):
	S[i] = int(S[i])
for i in range(n):
	N[S[i]] += 1
for i in range(0, 2 * 100000 + 1):
	T[N[i]].append(i)
l = 0
p = 2 * 100000
while l < k:
	if len(T[p]) == 0:
		p -= 1
	else:
		if l < k - 1:
			print(T[p][-1], end=' ')
		else:
			print(T[p][-1])
		D[T[p][-1]] += 1
		l += 1
		T[N[T[p][-1]] // D[T[p][-1]]].append(T[p][-1])
		T[p].pop()


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
a = []
for j in range(2 * 10 ** 5 + 1):
	a.append([0, 0])
for j in range(n):
	if a[b[j]][0] == 0:
		a[b[j]][0] = 1
		a[b[j]][1] = b[j]
	else:
		a[b[j]][0] += 1
a.sort(reverse=True)
d = []
arr = []
for j in range(k):
	p = a[j][0]
	q = a[j][1]
	for i in range(1, p + 1):
		arr.append([p // i, q])
arr.sort(reverse=True)
f = []
for i in range(k):
	f.append(arr[i][1])
print(*f)


import heapq

def D():
	(n, k) = map(int, input().split())
	array = [int(x) for x in input().split()]
	counter = {}
	for element in array:
		if element in counter:
			counter[element] += 1
		else:
			counter[element] = 1
	s = [(count, key) for (key, count) in counter.items()]
	s.sort(reverse=True)
	ans = []
	for i in range(len(s)):
		divisor = 1
		while s[i][0] // divisor > 0:
			ans.append([[s[i][0] // divisor], s[i][1]])
			divisor += 1
	ans.sort(reverse=True)
	output = []
	for i in range(k):
		output.append(str(ans[i][1]))
	print(' '.join(output))
D()


import math
import heapq
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

def main():
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		d[s[i]] += 1

	def ok(m):
		cnt = 0
		for v in d.values():
			if v >= m:
				cnt += v // m
		if cnt >= k:
			return True
		else:
			return False
	(l, r) = (0, 10 ** 18)
	for i in range(100):
		m = (l + r) / 2
		if ok(m):
			l = m
		else:
			r = m
	m = int(m)
	ans = []
	cnt = 0
	for i in set(s):
		if d[i] >= m:
			for j in range(d[i] // m):
				ans.append(i)
				cnt += 1
				if cnt == k:
					print(*ans)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
dic = {}
for i in a:
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
temp = []
for i in dic:
	temp.append((dic[i], i))
temp.sort(reverse=True)
b = []
for i in range(len(temp)):
	j = 1
	while temp[i][0] // j != 0:
		b.append((temp[i][0] // j, temp[i][1]))
		j += 1
b.sort(reverse=True)
for i in range(k):
	print(b[i][1], end=' ')


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
cnt = {}
for x in s:
	cnt[x] = cnt.get(x, 0) + 1

def run(v):
	C = 0
	for x in cnt:
		C += cnt[x] // v
	return C
(lo, hi) = [0, 2 * 10 ** 5]
while lo < hi:
	mi = (lo + hi + 1) // 2
	if run(mi) >= k:
		lo = mi
	else:
		hi = mi - 1
ans = []
for x in cnt:
	for i in range(cnt[x] // lo):
		ans.append(x)
print(*ans[:k])


from collections import Counter
(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
c = Counter(l)
lista = []
for i in list(c.most_common()):
	j = 1
	while i[1] // j != 0:
		lista.append((i[1] // j, i[0]))
		j += 1
lista.sort(reverse=True)
print(' '.join([str(lista[x][1]) for x in range(k)]))


from collections import defaultdict
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
hash = defaultdict(int)
for i in range(n):
	hash[l[i]] += 1
ba = []
for i in hash.keys():
	for j in range(1, hash[i] + 1):
		ba.append([hash[i] // j, i])
ba.sort(reverse=True)
for i in range(k):
	print(ba[i][1], end=' ')


from collections import defaultdict, Counter
(n, k) = map(int, input().split())
s = list(map(int, input().split()))
C = Counter(s)

def get(p):
	ret = list()
	for (a, b) in C.items():
		ret += [a] * (b // p)
	return ret

def check(p):
	return len(get(p)) >= k

def binSearch(a, b):
	(left, right) = (a - 1, b + 1)
	while right - left > 1:
		mid = (left + right) // 2
		if check(mid):
			left = mid
		else:
			right = mid
	return left
print(' '.join(map(str, get(binSearch(1, n))[:k])))


def read_input():
	return list(map(int, input().split()))
from collections import Counter
(n, k) = read_input()
c = Counter(read_input())
l = []
for (a, b) in c.items():
	for i in range(1, b + 1):
		l.append((b // i, a))
l.sort(reverse=True)
print(' '.join((str(b) for (a, b) in l[:k])))


def sortbyInd(input_i):
	return input_i[1]
from collections import Counter
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
l = Counter(a)
li = [(i, l[i]) for i in list(l)]
res = []
for i in li:
	j = 1
	while i[1] // j != 0:
		res.append((i[0], i[1] // j))
		j += 1
res.sort(key=sortbyInd, reverse=True)
for i in range(k):
	print(res[i][0], end=' ')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = dict()
for i in range(n):
	if l[i] not in d:
		d.update({l[i]: 1})
	else:
		d[l[i]] += 1

def check(v):
	to = 0
	for j in sorted(d.values(), reverse=True):
		num = j // v
		if num == 0:
			return False
		else:
			to += num
		if to >= k:
			return True

def binary():
	l = 0
	r = n
	while l <= r:
		mid = (l + r + 1) // 2
		if check(mid) == True:
			l = mid
		else:
			r = mid - 1
		if l == mid == r:
			break
	return mid
v = binary()
ans = []
for j in d:
	num = d[j] // v
	for j1 in range(num):
		ans.append(j)
	if len(ans) >= k:
		break
print(*ans[:k], sep=' ')


def possible(x, a):
	pick = 0
	for i in range(200001):
		pick += cnt[i] // x
		if pick >= a:
			return 1
	return 0
cnt = [0] * 200001
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(n):
	cnt[arr[i]] += 1
lo = 1
hi = n // k
while lo < hi:
	mid = (lo + hi + 1) // 2
	if possible(mid, k):
		lo = mid
	else:
		hi = mid - 1
for i in range(200001):
	c = min(k, cnt[i] // lo)
	for j in range(c):
		print(i, end=' ')
	k -= c
print()


from collections import defaultdict
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
dic = defaultdict(int)
for i in arr:
	dic[i] += 1
arr = []
for i in dic:
	for j in range(1, dic[i] + 1):
		arr.append([i, dic[i] // j])
arr.sort(key=lambda x: x[1], reverse=True)
for i in range(k):
	print(arr[i][0], end=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * 200005
for x in a:
	cnt[x] += 1

def check(x):
	ans = 0
	for i in range(200005):
		ans += cnt[i] // x
	return ans >= k
(l, r, ans) = (1, n, 0)
while l <= r:
	m = (l + r) // 2
	if check(m):
		ans = m
		l = m + 1
	else:
		r = m - 1
for i in range(200005):
	while cnt[i] >= ans and k > 0:
		print(i, end=' ')
		k -= 1
		cnt[i] -= ans


from collections import defaultdict
from string import ascii_lowercase
from sys import stdin, stdout
input = stdin.readline

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt_dict = defaultdict(int)
	for val in a:
		cnt_dict[val] += 1

	def check(x):
		left = k
		res = []
		for (val, cnt) in cnt_dict.items():
			add = cnt // x
			if add > 0:
				add = min(left, add)
				left -= add
				for i in range(add):
					res.append(val)
			if left <= 0:
				break
		if left <= 0:
			return res
		return False
	L = 1
	R = n - 1
	ans = None
	while L + 1 < R:
		mid = (L + R) // 2
		ver = check(mid)
		if ver:
			ans = ver
			L = mid
		else:
			R = mid
	ver = check(L)
	if ver:
		ans = ver
	if R > 0:
		ver = check(R)
		if ver:
			ans = ver
	print(*ans)
main()


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(n, k) = mints()
a = list(mints())
c = [0] * 200002
for i in range(len(a)):
	c[a[i]] += 1
d = [None] * len(c)
for i in range(len(c)):
	d[i] = (c[i], i)
d.sort(reverse=True)

def can(z):
	c = 0
	i = 0
	(x, y) = d[i]
	r = [0] * k
	while c < k:
		if x >= z:
			x -= z
			r[c] = y
			c += 1
		else:
			i += 1
			if i >= len(d):
				return None
			(x, y) = d[i]
	return r
l = 0
r = d[0][0]
while l < r:
	c = (l + r + 1) // 2
	if can(c) != None:
		l = c
	else:
		r = c - 1
r = can(l)
if r == None:
	r = [1] * k
print(*r)


import collections as cc
I = lambda : list(map(int, input().split()))
(n, k) = I()
l = I()
f = {}
for i in l:
	f[i] = f.get(i, 0) + 1
lo = 1
hi = n
while lo < hi:
	mid = (lo + hi + 1) // 2
	temp = 0
	for j in f.values():
		temp += j // mid
	if temp >= k:
		lo = mid
	else:
		hi = mid - 1
tem = 0
aa = []
for x in f.keys():
	for i in range(f[x] // lo):
		if tem < k:
			aa.append(x)
			tem += 1
print(*aa)


import heapq
(n, k) = map(int, input().split())
arr = [int(i) for i in input().split(' ')]
cnt = {}
for el in arr:
	if el not in cnt:
		cnt[el] = 1
	else:
		cnt[el] += 1
h = [(-v, k) for (k, v) in cnt.items()]
heapq.heapify(h)
ans = []
t_cnt = {k: 0 for k in cnt}
while len(ans) < k:
	top = heapq.heappop(h)
	ans.append(str(top[1]))
	t_cnt[top[1]] += 1
	v2 = cnt[top[1]] / (t_cnt[top[1]] + 1)
	if v2 >= 1:
		heapq.heappush(h, (-v2, top[1]))
print(' '.join(ans))


from sys import stdin, stdout
(N, K) = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]
h = {}
for num in arr:
	if num not in h:
		h[num] = 1
	else:
		h[num] += 1
left = 1
right = max(h.values())
res = 0
while left <= right:
	mid = (left + right) // 2
	elm = 0
	flag = 0
	for key in h:
		if h[key] >= mid:
			elm += h[key] // mid
		if elm >= K:
			flag = 1
			break
	if flag == 1:
		res = max(res, mid)
		left = mid + 1
	else:
		right = mid - 1
ans = []
elm = 0
for key in h:
	while h[key] >= res:
		h[key] -= res
		ans.append(key)
		elm += 1
		if elm == K:
			print(*ans)
			quit()


from operator import itemgetter
(n, k) = map(int, input().split())
si = list(map(int, input().split()))
num = 10 ** 5 * 2 + 1
ai = [0] * num
for i in range(n):
	ai[si[i]] += 1
num3 = num
num = max(ai) + 1
ai2 = [[] for i in range(num)]
for i in range(num3):
	if ai[i] != 0:
		ai2[ai[i]] += [[i, 1, ai[i]]]
i = num - 1
while k > 0:
	for j in ai2[i]:
		if k == 0:
			break
		num2 = j[2] // (j[1] + 1)
		ai2[num2] += [[j[0], j[1] + 1, j[2]]]
		print(j[0], end=' ')
		k -= 1
	i -= 1


def f(m):
	ans = 0
	for i in range(2 * 10 ** 5 + 1):
		ans += cnt[i] // m
	if ans < k:
		return False
	else:
		return True
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * (2 * 10 ** 5 + 1)
for i in range(n):
	cnt[a[i]] += 1
l = 0
r = 2 * 10 ** 5
while r > l + 1:
	m = (l + r) // 2
	if f(m):
		l = m
	else:
		r = m
t = []
for i in range(2 * 10 ** 5 + 1):
	if cnt[i] // l > 0:
		for j in range(cnt[i] // l):
			t.append(i)
	if len(t) >= k:
		t = t[:k]
		break
print(*t)


from sys import stdin
import math
import heapq
import copy

def sort_by_frequency(n, arr):
	count = [0] * (2 * 10 ** 5 + 1)
	for i in range(n):
		count[arr[i]] += 1
	freq = []
	for i in range(len(count)):
		if count[i] != 0:
			freq.append([-count[i], i])
	return freq
(n, k) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
if n == k:
	print(*arr)
	exit()
freq = sort_by_frequency(n, arr)
pq = []
heapq.heapify(pq)
for i in range(len(freq)):
	heapq.heappush(pq, freq[i])
	for j in range(2, -freq[i][0] + 1):
		heapq.heappush(pq, [-(-freq[i][0] // j), freq[i][1]])
for _ in range(k):
	print(heapq.heappop(pq)[1], end=' ')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
from collections import Counter

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def getint():
	return int(input())

def getints():
	return list(map(int, input().split()))

def getint1():
	return list(map(lambda x: int(x) - 1, input().split()))

def count(copies, countdict, k):
	K = 0
	for key in countdict:
		K += countdict[key] // copies
	return K >= k

def main():
	(n, k) = getints()
	s = Counter(getints())
	(l, h) = (1, 2 * 10 ** 5)
	while l < h:
		mid = (l + h) // 2
		bk = count(mid, s, k)
		if bk:
			l = mid
		else:
			h = mid - 1
		if l + 1 == h:
			mid = h
			bk = count(mid, s, k)
			if bk:
				l = mid
			break
	ans = []
	for i in s:
		ans.extend(s[i] // l * [i])
	print(*ans[:k])
main()


from sys import stdin
(n, k) = map(int, stdin.readline().split())
s = list(map(int, stdin.readline().split()))
count = [0 for i in range(2 * 100000 + 1)]
for ele in s:
	count[ele] += 1
count = [(count[i], i) for i in range(2 * 100000 + 1)]
res = list()
l = 0
r = n
while l < r:
	res = list()
	mid = (l + r) // 2 + (l + r) % 2
	cnt = 0
	for ele in count:
		ths = ele[0] // mid
		cnt += ths
	if cnt < k:
		r = mid - 1
	else:
		l = mid
for ele in count:
	ths = ele[0] // l
	for i in range(ths):
		res.append(ele[1])
print(' '.join([str(x) for x in res[:k]]))


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
freq = []
d = {}
for i in arr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in d:
	freq.append([d[i], i])
freq.sort()
freq = freq[-1::-1]
size = 0
(l, r) = (1, n)
while l < r:
	mid = (r + l) // 2
	h = 0
	for i in freq:
		(f, num) = (i[0], i[1])
		h += f // mid
		if h >= k:
			break
	if h >= k:
		if size < mid:
			size = mid
		l = mid
	else:
		r = mid
	if r - l == 1:
		break
h = 0
for i in freq:
	(f, num) = (i[0], i[1])
	times = f // r
	h += times
	if h >= k:
		break
if h >= k:
	if size < r:
		size = r
h = 0
for i in freq:
	(f, num) = (i[0], i[1])
	times = f // l
	h += times
	if h >= k:
		break
if h >= k:
	if size < l:
		size = l
ans = []
total = k
for i in freq:
	if total == 0:
		break
	(s, num) = (i[0], i[1])
	times = s // size
	x = min(total, times)
	ans += [num] * x
	total -= x
print(*ans)


import math
import bisect
import itertools
import sys
mod = 10 ** 9 + 7

def mindiff(a):
	b = a[:]
	b.sort()
	m = 10000000000
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] < m:
			m = b[i + 1] - b[i]
	return m

def lcm(a, b):
	return a * b // math.gcd(a, b)

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1

def binsearch(arr, b, low, high):
	if low == high:
		return low
	if arr[math.ceil((low + high) / 2)] < b:
		return binsearch(arr, b, low, math.ceil((low + high) / 2) - 1)
	else:
		return binsearch(arr, b, math.ceil((low + high) / 2), high)

def ncr1(n, r):
	s = 1
	for i in range(min(n - r, r)):
		s *= n - i
		s %= mod
		s *= pow(i + 1, mod - 2, mod)
		s %= mod
	return s

def calc(n, m, r):
	s = 0
	for i in range(0, r + 1, 2):
		s += ncr1(n, i) * ncr1(m, i)
		s %= mod
	return s

def bin(d, low, high, k):
	if low == high:
		return low
	elif check(d, ceil(low + high, 2), k):
		return bin(d, ceil(low + high, 2), high, k)
	else:
		return bin(d, low, ceil(low + high, 2) - 1, k)

def check(d, p, k):
	count = 0
	for i in d:
		count += d[i] // p
	if count >= k:
		return True
	else:
		return False
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in a:
	d[i] = d.get(i, 0) + 1
p = n // k
count = 0
ans = bin(d, 1, p, k)
for i in d:
	print(min(d[i] // ans, k) * (str(i) + ' '), end='')
	count = min(d[i] // ans, k)
	k -= count
	if k <= 0:
		break


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def find(mid, c):
	ans = []
	for i in c:
		p = c[i] // mid
		for j in range(p):
			ans.append(i)
	return ans

def case():
	(n, k) = li()
	a = li()
	(l, r) = (1, 200000)
	m = []
	c = Counter(a)
	while l <= r:
		mid = (l + r) // 2
		b = find(mid, c)
		if len(b) >= k:
			m = b
			l = mid + 1
		else:
			r = mid - 1
	print(*m[:k])
for _ in range(1):
	case()


from collections import Counter
(_, goal) = [*map(int, input().split())]
a = [*map(int, input().split())]
counts = Counter(a).items()
val = []
for (m, l) in counts:
	for i in range(1, l + 1):
		val.append((m, l // i))
s = sorted(val, key=lambda x: x[1])[-goal:]
res = [m for (m, l) in s]
print(*res)


def check(m, z):
	i = 0
	for j in range(z):
		i += poj[j] // m
	if i < k:
		return False
	else:
		return True
(n, k) = map(int, input().split())
s = list(map(int, input().split()))
z = max(s)
poj = [0 for i in range(z)]
rj = []
for i in range(n):
	poj[s[i] - 1] += 1
l = 1
r = n
while r > l + 1:
	m = (l + r) // 2
	if check(m, z) == True:
		l = m
	else:
		r = m
for i in range(z):
	for j in range(poj[i] // l):
		rj.append(i)
	if len(rj) >= k:
		break
for i in range(0, k):
	print(rj[i] + 1, end=' ')


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
m = {}
for i in l:
	m[i] = 0
for i in l:
	m[i] += 1
l = []
for i in m:
	l.append([m[i], i])
l = sorted(l)
for i in range(len(l) // 2):
	(l[i], l[len(l) - 1 - i]) = (l[len(l) - 1 - i], l[i])
left = 1
right = n
mid = 1
req = 1
while left <= right:
	mid = (left + right) // 2
	cur = k
	for i in l:
		cur -= i[0] // mid
	if cur <= 0:
		req = mid
		left = mid + 1
	else:
		right = mid - 1
REQ = []
for i in l:
	q = i[0]
	v = i[1]
	while k > 0 and q - req >= 0:
		k -= 1
		q -= req
		REQ.append(v)
for i in REQ:
	print(i, end=' ')


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from sys import stdin
from collections import Counter, deque
from math import ceil
(n, k) = arr_inp()
s = arr_inp()
mem = Counter(s).most_common()
if k > n // 2 or mem[0][1] == 1:
	exit(print(*[s[i] for i in range(k)]))
if len(mem) == 1:
	exit(print(*[mem[0][0] for i in range(k)]))
(diff, p1, ans, total, tem) = (mem[0][1] / k, 1, [], mem[0][1], deque([mem[0]]))
while p1 < len(mem) and diff <= mem[p1][1]:
	diff += mem[p1][1] / k
	tem.append(mem[p1])
	total += mem[p1][1]
	p1 += 1
for i in range(len(tem)):
	num = tem[0][1] / total * k
	if num - 0.5 >= int(num):
		num = ceil(num)
	else:
		num = int(num)
	ans.extend([tem[0][0] for j in range(num)])
	tem.rotate(-1)
print(*ans[:k])


import sys
input = sys.stdin.readline
from collections import Counter

def judge(x):
	c = 0
	for v in cnt.values():
		c += v // x
	return c >= k

def binary_search():
	(l, r) = (1, n // k)
	while l <= r:
		mid = (l + r) // 2
		if judge(mid):
			l = mid + 1
		else:
			r = mid - 1
	return r
(n, k) = map(int, input().split())
s = list(map(int, input().split()))
cnt = Counter(s)
b = binary_search()
c = 0
ans = []
for (n, v) in cnt.items():
	if k - c <= v // b:
		for _ in range(k - c):
			ans.append(n)
		break
	else:
		for _ in range(v // b):
			ans.append(n)
		c += v // b
print(*ans)


from collections import Counter

def check(num):
	count = 0
	for i in freq:
		count += i[0] // num
	if count >= k:
		return True
	return False
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
c = Counter(l)
freq = []
for i in c:
	freq.append((c[i], i))
freq.sort(reverse=True)
low = 1
high = 10 ** 6
while low < high:
	mid = (low + high) // 2
	if check(mid):
		low = mid + 1
	else:
		high = mid - 1
if check(low):
	low = low
else:
	low = low - 1
ans = []
for i in freq:
	for j in range(max(1, i[0] // low)):
		ans.append(i[1])
		if len(ans) == k:
			break
	if len(ans) == k:
		break
print(*ans)


(n, k) = map(int, input().split())
if n == k:
	a = input()
	print(a)
else:
	a = list(map(int, input().split()))
	import collections
	alfa = collections.Counter(a)
	dopi = []
	for i in alfa:
		j = 1
		while alfa[i] >= j:
			dopi.append([i, alfa[i] // j])
			j += 1
	dopi.sort(key=lambda x: x[1], reverse=True)
	ans = ''
	for i in range(k):
		ans += ' ' + str(dopi[i][0])
	print(ans[1:])


def can(val):
	t = k
	for i in range(1, L[n - 1] + 1):
		if cnt[i] >= val:
			t -= cnt[i] // val
		if t <= 0:
			return 1
	return 0
(n, k) = map(int, input().split())
L = sorted(map(int, input().split()))
cnt = [0] * (L[n - 1] + 1)
for i in L:
	cnt[i] += 1
ans = 0
(l, r) = (1, n)
while l <= r:
	m = (l + r) // 2
	if can(m):
		l = m + 1
		ans = max(ans, m)
	else:
		r = m - 1
res = []
t = k
for i in range(1, L[n - 1] + 1):
	if t > 0:
		if cnt[i] >= ans:
			res += [i] * (cnt[i] // ans)
			t -= cnt[i] // ans
	else:
		break
print(*res[:k])


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
for i in l:
	d[i] += 1
L = []
for i in set(l):
	L.append([d[i], i])
l = []
for (n, i) in L:
	j = 1
	while n // j != 0:
		l.append([n // j, i])
		j += 1
l.sort(reverse=True)
for i in range(k):
	print(l[i][1], end=' ')


from collections import Counter
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
cnt = Counter(arr)
x = cnt.most_common()

def p(y):
	t = 0
	for c in x:
		t += c[1] // y
	if t < k:
		return False
	else:
		return True
low = 1
high = n + 1
while low < high:
	mid = low + (high - low) // 2
	if p(mid):
		low = mid + 1
	else:
		high = mid
ans = low - 1
u = ans * k
ans = []
for y in x:
	ans.append(y[0])
	u -= y[1] // (low - 1)
	if u == 0:
		break
final_ans = []
for y in ans:
	final_ans += [y] * min(cnt[y] // (low - 1), k)
	k -= min(cnt[y] // (low - 1), k)
print(*final_ans)


from collections import Counter

def cheaker(z, mid):
	an = k
	y = []
	for i in z:
		an -= z[i] // mid
		if an <= 0:
			an += z[i] // mid
			y.extend([i] * an)
			an = 0
			break
		y.extend([i] * (z[i] // mid))
	if an != 0:
		return [False, []]
	else:
		return [True, y]
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
z = Counter(a)
v = []
up = n
do = 1
while up >= do:
	mid = (up + do) // 2
	q = cheaker(z, mid)
	if q[0]:
		an = q[1]
		do = mid + 1
	else:
		up = mid - 1
print(*an)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
dic = {}
for i in range(n):
	if a[i] in dic:
		dic[a[i]] = dic[a[i]] + 1
	else:
		dic[a[i]] = 1
freq = []
for (i, j) in dic.items():
	freq.append([i, j])
freq.sort()
freq.reverse()
low = 1
high = n
take = 1
while low <= high:
	mid = int((low + high) / 2)
	avi = 0
	for i in range(len(freq)):
		avi += int(freq[i][1] / mid)
	if avi >= k:
		take = mid
		low = mid + 1
	else:
		high = mid - 1
cnt = 0
ans = []
for i in range(len(freq)):
	times = int(freq[i][1] / take)
	for j in range(times):
		++cnt
		ans.append(freq[i][0])
for i in range(k):
	print(ans[i])


import os
import sys
from io import BytesIO, IOBase

def check(mid, x, k):
	z = 0
	for i in x:
		z += i[0] // mid
		if z >= k:
			return 1
	return 0

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ma = max(a)
	b = [0] * (ma + 1)
	for i in a:
		b[i] += 1
	c = []
	for i in range(1, ma + 1):
		if b[i]:
			c.append([b[i], i])
	(lo, hi, ans) = (1, n, 0)
	while lo <= hi:
		mid = (lo + hi) // 2
		if check(mid, c, k):
			ans = mid
			lo = mid + 1
		else:
			hi = mid - 1
	d = []
	for i in c:
		for j in range(i[0] // ans):
			d.append(i[1])
	print(*d[:k])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os, sys
from io import BytesIO, IOBase

def check(vals, mid, k):
	tup = []
	for i in vals:
		z = min(k, i[1] // mid)
		if z:
			tup.extend([i[0]] * z)
			k -= z
		if not k:
			return tup
	return 0

def main():
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	X = max(s)
	arr = [0] * (X + 1)
	for i in s:
		arr[i] += 1
	vals = []
	for (ind, i) in enumerate(arr):
		if i:
			vals.append((ind, i))
	(hi, lo, ans) = (n, 1, 0)
	while hi >= lo:
		mid = (hi + lo) // 2
		r = check(vals, mid, k)
		if r:
			ans = r
			lo = mid + 1
		else:
			hi = mid - 1
	print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()