Sam is a kindergartener, and there are $n$ children in his group. He decided to create a team with some of his children to play "brawl:go 2".

Sam has $n$ power-ups, the $i$-th has type $a_i$. A child's strength is equal to the number of different types among power-ups he has.

For a team of size $k$, Sam will distribute all $n$ power-ups to $k$ children in such a way that each of the $k$ children receives at least one power-up, and each power-up is given to someone.

For each integer $k$ from $1$ to $n$, find the minimum sum of strengths of a team of $k$ children Sam can get.


-----Input-----

Each test contains multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 3 \cdot 10^5$) — the number of test cases. Description of the test cases follows.

The first line of each test case contains a single integer $n$ ($1 \le n \le 3 \cdot 10^5$).

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — types of Sam's power-ups.

It is guaranteed that the sum of $n$ over all test cases does not exceed $3 \cdot 10^5$.


-----Output-----

For every test case print $n$ integers.

The $k$-th integer should be equal to the minimum sum of strengths of children in the team of size $k$ that Sam can get.


-----Examples-----

Input
2
3
1 1 2
6
5 1 2 2 2 4
Output
2 2 3 
4 4 4 4 5 6


-----Note-----

One of the ways to give power-ups to minimise the sum of strengths in the first test case:

$k = 1: \{1, 1, 2\}$

$k = 2: \{1, 1\}, \{2\}$

$k = 3: \{1\}, \{1\}, \{2\}$

One of the ways to give power-ups to minimise the sum of strengths in the second test case:

$k = 1: \{1, 2, 2, 2, 4, 5\}$

$k = 2: \{2, 2, 2, 4, 5\}, \{1\}$

$k = 3: \{2, 2, 2, 5\}, \{1\}, \{4\}$

$k = 4: \{2, 2, 2\}, \{1\}, \{4\}, \{5\}$

$k = 5: \{2, 2\}, \{1\}, \{2\}, \{4\}, \{5\}$

$k = 6: \{1\}, \{2\}, \{2\}, \{2\}, \{4\}, \{5\}$

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms


Solutions:
from enum import Enum, auto
import copy
import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		x = len(set(a))
		res = []
		for i in range(n):
			res.append(x if i < x else i + 1)
		print(' '.join(list(map(str, res))))
main()


t = int(input())
out = []
for time in range(t):
	n = int(input())
	a = list(input().split())
	sa = len(set(a))
	output = []
	for x in range(1, n + 1):
		if x <= sa:
			output.append(sa)
		else:
			output.append(x)
	out.append(' '.join((str(n) for n in output)))
for x in out:
	print(x)


import random

def A():
	N = int(input())
	answers = []
	for i in range(N):
		(x1, y1) = [int(n) for n in input().split()]
		(x2, y2) = [int(n) for n in input().split()]
		(x3, y3) = [int(n) for n in input().split()]
		if y1 == y2:
			if y3 > y2:
				answers.append(0)
			else:
				answers.append(abs(x2 - x1))
		elif y2 == y3:
			if y1 > y2:
				answers.append(0)
			else:
				answers.append(abs(x2 - x3))
		elif y1 == y3:
			if y2 > y3:
				answers.append(0)
			else:
				answers.append(abs(x3 - x1))
		else:
			answers.append(0)
	for ans in answers:
		print(ans)

def B():
	N = int(input())
	answers = []
	for _ in range(N):
		n = int(input())
		types = input().split()
		type_dict = {}
		for s in types:
			D = type_dict.setdefault(s, 0)
			D += 1
			type_dict[s] = D
		ans = ''
		p = len(type_dict.keys())
		ans += f'{p} ' * p
		for c in type_dict:
			for i in range(0, type_dict[c] - 1):
				p += 1
				ans += f'{p} '
		answers += [ans[:-1]]
	for ans in answers:
		print(ans)
B()


t = int(input())
res = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = len(list(set(a)))
	c = n - b
	r = [b] * b
	if c != 0:
		r2 = list(range(b + 1, n + 1))
		r = r + r2
	res.append(' '.join(map(str, r)))
for i in range(len(res)):
	print(res[i])


import math
import sys
import statistics
from statistics import mode
input = sys.stdin.readline

def inp_int():
	return int(input())

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

def inp_string():
	s = input()
	return list(s[:len(s) - 1])

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

def solve():
	n = inp_int()
	lst = inp_list()
	unq_len = len(set(lst))
	ans = []
	for i in range(1, n + 1):
		ans.append(max(i, unq_len))
	ans = ' '.join((str(e) for e in ans))
	print(ans)
number_cases = inp_int()
for x in range(number_cases):
	solve()


for s in [*open(0)][2::2]:
	a = s.split()
	m = len({*a})
	print(*(max(m, i + 1) for i in range(len(a))))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	w = list(map(int, input().split()))
	s = len(set(w))
	print(*[s] * s + list(range(s + 1, n + 1)))


from sys import stdin
input = stdin.readline

def main():
	for _ in range(int(input())):
		n = int(input())
		s = set(list(map(int, input().split())))
		l = len(s)
		print(*[l for i in range(l)], *[i for i in range(l + 1, n + 1)])
main()


t = int(input())
arr = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	arr.append(a)

def helper(ar, n):
	m = n
	ans = ''
	j = 1
	count = m
	for i in range(len(ar)):
		if count > 0:
			if not ans:
				ans += str(m)
			else:
				ans += ' ' + str(m)
			count -= 1
		else:
			ans += ' ' + str(m + j)
			j += 1
	return ans
for i in range(t):
	s = set(arr[i])
	n = len(s)
	print(helper(arr[i], n))


def power_walking(np: int, n: int) -> str:
	s = (str(np) + ' ') * np
	for i in range(np + 1, n + 1):
		s += str(i) + ' '
	return s
test_number = int(input())
res = []
for _ in range(test_number):
	n = int(input())
	power_ups = set((int(x) for x in input().split()))
	np = len(power_ups)
	res.append(power_walking(np, n))
for r in res:
	print(r)


import sys

def solver(n, uniques):
	for i in range(1, n + 1):
		if i > uniques:
			print(i, end=' ')
		else:
			print(uniques, end=' ')
	print()
input = sys.stdin.readline
tests = int(input())
while tests:
	n = int(input())
	types = set(map(int, input().split()))
	solver(n, len(types))
	tests -= 1


t = int(input())
ll = []
for i in range(t):
	pl = []
	n = int(input())
	l = input().split()
	total = len(l)
	l = list(dict.fromkeys(l))
	nodupe = len(l)
	for j in range(nodupe):
		pl.append(nodupe)
	while nodupe < total:
		nodupe += 1
		pl.append(nodupe)
	x = ''
	for j in pl:
		x += str(j)
		x += ' '
	ll.append(x)
for i in ll:
	print(i)


from sys import stdin
t = int(stdin.readline())
while t > 0:
	t -= 1
	n = int(stdin.readline())
	L = len(set(map(int, stdin.readline().split())))
	print(*[L] * L + list(range(L + 1, n + 1)), '\n')


t = int(input())
n_list = []
unique_powerup_list = []
for i1 in range(t):
	temp_array = []
	n = int(input())
	n_list.append(n)
	in1 = input().split()
	unique_powerup_list.append(len(set(in1)))
for i2 in range(t):
	unique_powerup = unique_powerup_list[i2]
	n = n_list[i2]
	for k in range(1, n + 1):
		if k > unique_powerup:
			print(k, end=' ')
		else:
			print(unique_powerup, end=' ')
	print()


n = int(input())
i = 0
ans = []
while i < n:
	a = int(input())
	b = input().split(' ')
	c = len(set(b))
	s = c * [c] + list(range(c + 1, a + 1))
	print(' '.join(map(str, s)))
	i += 1


import sys
import bisect
inp = sys.stdin.readline

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

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(inp())):
	n = int(inp())
	a = {int(i) for i in inp().split()}
	for i in range(1, n + 1):
		print(max(i, len(a)), end=' ')
	print()


from sys import stdin, stdout
from collections import defaultdict, Counter
import math
input = stdin.readline
t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	arr = list(map(int, input().strip().split()))
	d = Counter(arr)
	total = len(d)
	res = [total] * total
	res += list(range(total + 1, n + 1))
	print(*res)


def count_num_type(string_tp):
	a = string_tp.split(' ')
	dic = dict()
	for i in a:
		if i in dic:
			dic[i] = dic[i] + 1
		else:
			dic[i] = 1
	return len(dic)

def print_string(vol, numtypes):
	o_str = (str(numtypes) + ' ') * numtypes
	for i in range(vol - numtypes):
		o_str = o_str + '{} '.format(numtypes + (i + 1))
	print(o_str[:len(o_str)])
test_cases = int(input())
for i in range(test_cases):
	n = int(input())
	types = input()
	numoftype = count_num_type(types)
	print_string(n, numoftype)


def count_num_type(string_tp):
	a = string_tp.split(' ')
	dic = dict()
	for i in a:
		if i in dic:
			dic[i] = dic[i] + 1
		else:
			dic[i] = 1
	return len(dic)
test_cases = int(input())
lis = list()
for i in range(test_cases):
	n = int(input())
	types = input()
	numoftype = count_num_type(types)
	a = (str(numoftype) + ' ') * numoftype
	for i in range(n - numoftype):
		a = a + '{} '.format(numoftype + (i + 1))
	print(a[:len(a)])


n = int(input())
l = []
for i in range(n):
	x = input()
	l.append(list(map(int, input().split())))

def fun1(l1):
	x = len(set(l1))
	for i in range(1, len(l1) + 1):
		if i <= x:
			print(x, end=' ')
		else:
			print(x + (i - x), end=' ')
	print()
for l1 in l:
	fun1(l1)


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
mod = 10 ** 9 + 7
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	dict = {}
	for i in range(n):
		if arr[i] not in dict:
			dict[arr[i]] = 1
		else:
			dict[arr[i]] += 1
	x = len(dict)
	for i in range(x):
		print(x, end=' ')
	curr = x + 1
	for i in range(x + 1, n + 1):
		print(curr, end=' ')
		curr += 1
	print()


from sys import stdin, stdout

def GetListOrder(myList):
	myList.sort()
	cnt = 0
	cur = 0
	for a in myList:
		if a > cur:
			cnt += 1
			cur = a
	return cnt
t = int(stdin.readline())
for i in range(t):
	n = int(stdin.readline())
	power_up_list = list(map(int, stdin.readline().strip().split(None, n)))[:n]
	order = GetListOrder(power_up_list)
	output = ''
	for j in range(n):
		if j < order:
			output += str(order) + ' '
		else:
			output += str(j + 1) + ' '
	print(output.strip())


t = int(input())

def solve(a):
	diff = set(a)
	num = len(diff)
	r = [str(num)] * num
	for _ in range(num, len(a)):
		num += 1
		r.append(str(num))
	return ' '.join(r)
for _ in range(t):
	n = input()
	a = [int(e) for e in input().split()]
	print(solve(a))


import collections
import sys
input = sys.stdin.readline

def solve(arr, n):
	counter = {}
	for num in arr:
		if num not in counter:
			counter[num] = 0
		counter[num] += 1
	c = [counter[v] for v in counter]
	c.sort()
	curr = len(set(arr))
	ans = [curr] * curr
	for i in c:
		if i == 1:
			continue
		else:
			for _ in range(i - 1):
				curr += 1
				ans.append(curr)
	print(*ans[:n])
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	solve(arr, n)


for i in range(int(input())):
	n = int(input())
	a = input().split()
	l = len(set(a))
	s = ''
	for i in range(l):
		s += str(l) + ' '
	for i in range(n - l):
		l += 1
		s += str(l) + ' '
	print(s)


out = []
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	cnt = 1
	for i in range(1, n):
		if a[i] != a[i - 1]:
			cnt += 1
	ans = [cnt] * cnt
	for i in range(n - cnt):
		ans.append(cnt + i + 1)
	out.append(ans)
for i in out:
	print(*i)


def solve():
	n = int(input())
	powerups = input().split()
	unique_ups = len(set(powerups))
	ans = []
	for k in range(1, n + 1):
		ans.append(max(k, unique_ups))
	print(' '.join([str(x) for x in ans]))
for tc in range(int(input())):
	solve()


def solve(powers):
	types = len(set(powers))
	final = []
	extra = 0
	for (i, power) in enumerate(powers):
		if i + 1 > types:
			extra += 1
		final.append(str(types + extra))
	print(' '.join(final))
t = int(input())
for _ in range(t):
	n = int(input())
	powers = [int(i) for i in input().split()]
	solve(powers)


from itertools import accumulate
from collections import Counter
T = int(input())

def printlist(l):
	ll = [str(c) for c in l]
	print(' '.join(ll))
for _ in range(T):
	n = int(input())
	A = [int(c) for c in input().split(' ')]
	k = len(set(A))
	l = k * [k] + list(range(k + 1, n + 1))
	printlist(l)


import sys
t = int(input())
for i in range(t):
	n = int(input())
	a = list(input().split())
	b = set(a)
	if len(b) == len(a):
		print(*[len(a) for i in range(len(a))])
	else:
		l = [len(b) for i in range(len(b))] + [i for i in range(len(b) + 1, len(a) + 1)]
		sys.stdout.write(' '.join(map(str, l)) + '\n')


import sys, collections
input = sys.stdin.readline
arr = int(input())
res = []
for _ in range(arr):
	n = int(input())
	massiv = list(map(int, input().split()))
	obj = collections.defaultdict(lambda : 0)
	count = 0
	for x in massiv:
		if obj[x] == 0:
			count += 1
		obj[x] += 1
	for i in range(1, n + 1):
		if i <= count:
			print(count, end=' ')
		else:
			count += 1
			print(count, end=' ')
	print()


test = int(input())
for _ in range(test):
	n = int(input())
	el = len(set(input().split()))
	result = [str(max(i + 1, el)) for i in range(n)]
	print(' '.join(result))


import sys
from collections import Counter

def func_B(improvements):
	improvements_counter = Counter(improvements)
	result = [len(improvements_counter) for _ in range(len(improvements_counter))]
	result += [len(improvements_counter) + i for i in range(1, len(improvements) - len(improvements_counter) + 1)]
	return result

def main():
	reader = (list(map(int, line.split())) for line in sys.stdin)
	t = next(reader)[0]
	for _ in range(t):
		_ = next(reader)
		print(*func_B(next(reader)))
main()


import sys, collections
input = sys.stdin.readline
tcs = int(input())
res = []
for _ in range(tcs):
	n = int(input())
	arr = list(map(int, input().split()))
	hp = collections.defaultdict(lambda : 0)
	sz = 0
	for x in arr:
		if hp[x] == 0:
			sz += 1
		hp[x] += 1
	for i in range(1, n + 1):
		if i <= sz:
			print(sz, end=' ')
		else:
			sz += 1
			print(sz, end=' ')
	print()


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

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
tests = inp()
for j in range(tests):
	total = inp()
	powers = inlt()
	group = defaultdict(int)
	for i in powers:
		group[i] += 1
	min_ = len(group)
	ans = []
	for x in range(1, total + 1):
		if x <= min_:
			ans.append(min_)
			print(min_, end=' ')
		else:
			print(ans[-1] + 1, end=' ')
			ans.append(ans[-1] + 1)
	print('')


for i in range(int(input())):
	lenn = int(input())
	powers = list(map(int, input().split()))
	new = sorted(powers)
	diff = 0
	for i in range(lenn - 1):
		if new[i] == new[i + 1]:
			diff += 1
	diff = lenn - diff
	output = (str(diff) + ' ') * diff
	for i in range(diff + 1, lenn + 1):
		output += str(i) + ' '
	print(output)


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	l = {}
	k = len(set(a))
	s = [str(k)] * k
	for i in range(n - k):
		s.append(str(k + i + 1))
	print(' '.join(s))


t = int(input())
for _ in range(t):
	n = int(input())
	types = set([int(x) for x in input().split()])
	type_count = len(types)
	nums = []
	for k in range(1, n + 1):
		nums.append(str(max(type_count, k)))
	print(' '.join(nums))


for t in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	s = set(ls)
	ans = list()
	ln = len(s)
	for i in range(n):
		if i < ln:
			ans.append(ln)
		else:
			ans.append(i + 1)
	print(' '.join(list(map(str, ans))))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = len(set(a))
	z = ' '.join((str(max(j, x)) for j in range(1, n + 1)))
	print(z)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	k = len(set(arr))
	b = []
	while n:
		b.append(str(max(k, n)))
		n -= 1
	print(' '.join(b[::-1]))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr1 = set(arr)
	a = len(arr1)
	ans = []
	for i in range(1, n + 1):
		if i <= a:
			ans.append(a)
		else:
			ans.append(i)
	str_ans = [str(x) for x in ans]
	print(' '.join(str_ans))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	st = set(a)
	ans = []
	for i in range(n):
		if i + 1 <= len(st):
			ans.append(str(len(st)))
		else:
			ans.append(str(i + 1))
	print(' '.join(ans))


def strengths(powerups):
	output = ''
	n = len(powerups)
	powerups = set(powerups)
	for i in range(1, n + 1):
		if i > len(powerups):
			output += str(i)
			output += ' '
		else:
			output += str(len(powerups))
			output += ' '
	print(output)
cases = int(input())
for _ in range(cases):
	n = int(input())
	powerups = []
	powerups = list(map(int, input().split()))
	strengths(powerups)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	S = set(A)
	ans = ''
	for i in range(len(S)):
		ans += ' ' + str(len(S))
	if len(A) == len(S):
		print(ans)
	else:
		for i in range(len(S), n):
			ans += ' ' + str(i + 1)
		print(ans)


nbTest = int(input())
for testN in range(nbTest):
	n = int(input())
	values = [int(i) for i in input().split()]
	nbDist = len(set(values))
	res = []
	for k in range(1, n + 1):
		res.append(str(max(nbDist, k)))
	print(' '.join(res))


for i in range(int(input())):
	n = int(input())
	a = input().split()
	a = list(map(int, a))
	b = list(dict.fromkeys(a))
	c = []
	d = len(b)
	for i in range(len(b)):
		c.append(len(b))
	e = n - len(b)
	for i in range(e):
		d += 1
		c.append(d)
	c = list(map(str, c))
	print(' '.join(c))


for _ in range(int(input())):
	n = int(input())
	l = len(set(map(int, input().split())))
	p = ''
	for i in range(n):
		p += str(max(i + 1, l))
		p += ' '
	print(p)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	types = len(set(l))
	res = [max(types, i) for i in range(1, n + 1)]
	print(' '.join(list(map(str, res))))


class Solution:

	def powerWalking(self, n, arr):
		types = set(arr)
		results = []
		for i in range(len(types)):
			results.append(len(types))
		for i in range(len(types), n):
			results.append(i + 1)
		return results
T = int(input())
sol = Solution()
for t in range(T):
	n = int(input())
	a = list()
	line = input()
	a = list(map(lambda x: int(x), list(line.split(' '))))
	results = sol.powerWalking(n, a)
	print(' '.join(map(lambda x: str(x), results)))


cases = int(input())
for i in range(0, cases):
	input()
	a = list(map(lambda n: int(n), input().split(' ')))
	aa = len(set(a))
	res = []
	for j in range(1, len(a) + 1):
		res.append(str(max(aa, j)))
	print(' '.join(res))


t = int(input())
for _ in range(0, t):
	n = int(input())
	list1 = [int(num) for num in input().split()]
	set1 = set(list1)
	l = len(set1)
	i = 0
	s = ''
	for i in range(0, l):
		s += str(l) + ' '
	i = l + 1
	for i in range(l + 1, n + 1):
		s += str(i) + ' '
	print(s.strip())


from collections import OrderedDict, defaultdict
for _ in range(int(input())):
	n = int(input())
	x = len(set(map(int, input().split())))
	p = [x] * (x - 1)
	print(*p + list(range(x, n + 1)))


for _ in range(int(input())):
	n = int(input())
	arr = map(int, input().split())
	l = len(set(arr))
	ans = [l] * l
	for k in range(1, n - l + 1):
		ans.append(l + k)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(input().split())
	b = set(a)
	if len(b) == len(a):
		print(*[len(a) for i in range(len(a))])
	else:
		l = [len(b) for i in range(len(b))] + [i for i in range(len(b) + 1, len(a) + 1)]
		print(*l)


test = int(input())
for t in range(test):
	n = int(input())
	powers = list(map(int, input().split()))[:n]
	arr = list(set(powers))
	dist = len(arr)
	i = dist + 1
	ans = []
	while len(ans) < n:
		if len(ans) < dist:
			ans.append(str(dist))
		else:
			ans.append(str(i))
			i += 1
	result = ' '.join(ans)
	print(result)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	cur = len(list(set(arr)))
	res = [cur] * cur
	while len(res) < n:
		res.append(res[-1] + 1)
	print(*res)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	count = len(set(l))
	ret = [count] * count + list(range(count + 1, n + 1))
	print(*ret)


from collections import Counter
k = int(input())
li = []
for i in range(k):
	input()
	li += [[int(b) for b in input().split()]]
l = []
for i in range(k):
	o = len(Counter(li[i]))
	u = [o for f in range(len(li[i]))]
	for h in range(o, len(li[i])):
		u[h] = u[h - 1] + 1
	l += [u]
for i in range(k):
	for g in l[i]:
		print(g, end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	x = list(map(int, input().split()))
	length = len(set(x))
	ans = ''
	for k in range(1, n + 1):
		ans += str(max(k, length)) + ' '
	print(ans)
	t -= 1


from collections import Counter
for tcase in range(int(input())):
	n = int(input())
	c = Counter(map(int, input().split()))
	nc = len(c)
	ans = [max(k, nc) for k in range(1, n + 1)]
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = len(set(a))
	p = [l] * l
	for _ in range(n - l):
		p.append(p[-1] + 1)
	print(*p)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = len(set(l))
	l2 = d * [d]
	l1 = list(range(d + 1, n + 1))
	y = l2 + l1
	print(*y)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))
	s = set(l)
	ls = len(s)
	lan = [ls] * ls
	for i in range(ls, n):
		ls += 1
		lan.append(ls)
	print(*lan)


for t in range(int(input())):
	n = int(input())
	a = set(map(int, input().split()))
	m = len(a)
	k = [m] * m
	e = m
	m = n - m
	for i in range(1, m + 1):
		k.append(e + i)
	print(*k)


from collections import Counter
t = int(input())
for r in range(t):
	n = int(input())
	lst = input().split()
	var = len(set(lst))
	for k in range(1, n + 1):
		if k <= var:
			print(var, end=' ')
		else:
			print(k, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	c = set(map(int, input().split()))
	print(*(max(i, len(c)) for i in range(1, n + 1)))


t = int(input())
for zz in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	p = len(list(set(l)))
	l1 = []
	for i in range(n):
		if i < p:
			l1.append(p)
		else:
			p += 1
			l1.append(p)
	print(*l1)


import sys
import math
ttime = int(input())
for ccount in range(ttime):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = len(set(a))
	for i in range(1, n + 1):
		sys.stdout.write(str(max(i, cnt)) + ' ')
	print()


for _ in range(int(input())):
	n = int(input())
	x = [int(i) for i in input().split()]
	s = set(x)
	k = len(s)
	for i in range(1, n + 1):
		if i <= k:
			print(k, end=' ')
		else:
			print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = set(map(int, input().split()))
	k = len(arr)
	ans = [k] * k + [k + i for i in range(1, n - k + 1)]
	print(*ans)


for t in range(int(input())):
	p = int(input())
	list1 = []
	o = list(map(int, input().split()))
	o1 = set(o)
	for i in range(len(o1)):
		list1.append(len(o1))
	for i in range(len(o1), len(o)):
		list1.append(i + 1)
	print(*list1)


for _ in range(int(input())):
	k = int(input())
	n = list(map(int, input().split()))
	s = set(n)
	sl = len(s)
	ans = [sl for i in range(sl)]
	for i in range(1, k - sl + 1):
		ans.append(sl + i)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	size = len(set(arr))
	for i in range(1, n + 1):
		if i <= size:
			print(size, end=' ')
		else:
			print(i, end=' ')
	print('\r')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	x = len(set(a))
	ans = [x for i in range(x)]
	for i in range(x + 1, n + 1):
		ans.append(i)
	print(*ans)