You are given an array $a$ consisting of $n$ integers numbered from $1$ to $n$.

Let's define the $k$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $k$ (recall that a subsegment of $a$ of length $k$ is a contiguous part of $a$ containing exactly $k$ elements). If there is no integer occuring in all subsegments of length $k$ for some value of $k$, then the $k$-amazing number is $-1$.

For each $k$ from $1$ to $n$ calculate the $k$-amazing number of the array $a$.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases. Then $t$ test cases follow.

The first line of each test case contains one integer $n$ ($1 \le n \le 3 \cdot 10^5$) — the number of elements in the array. The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$) — the elements of the array. 

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


-----Output-----

For each test case print $n$ integers, where the $i$-th integer is equal to the $i$-amazing number of the array.


-----Example-----
Input
3
5
1 2 3 4 5
5
4 4 4 4 2
6
1 3 1 5 3 1

Output
-1 -1 3 2 1 
-1 4 4 4 2 
-1 -1 1 1 1 1

Source: codeforces | Difficulty: MEDIUM


Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	a = [0] + list(map(int, input().split()))
	period = [0 for i in range(n + 1)]
	first = [-1 for i in range(n + 1)]
	last = [-1 for i in range(n + 1)]
	for i in range(1, len(a)):
		b = a[i]
		if first[b] == -1:
			first[b] = i
			last[b] = i
		else:
			period[b] = max(period[b], i - last[b])
			last[b] = i
	for i in range(1, len(period)):
		period[i] = max(period[i], n - last[i] + 1)
	period = period[1:]
	l = sorted(list((e if e[0] > first[e[1]] else (first[e[1]], e[1]) for e in zip(period, list(range(1, n + 1))) if e[0] > 0)))
	ans = []
	AA = n + 5
	ind = 0
	for i in range(1, n + 1):
		if ind < len(l) and l[ind][0] == i:
			AA = min(AA, l[ind][1])
		ans.append(-1 if AA == n + 5 else AA)
		while ind < len(l) and l[ind][0] == i:
			ind += 1
	print(*ans)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()

def pr(*args, end='\n'):
	for _arg in args:
		sys.stdout.write(str(_arg) + ' ')
	sys.stdout.write(end)
inf = float('inf')
enum = enumerate
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	last = [-1 for i in range(n + 1)]
	gap = [-1 for i in range(n + 1)]
	for i in range(n):
		gap[a[i]] = max(gap[a[i]], i - last[a[i]])
		last[a[i]] = i
	for i in a:
		gap[i] = max(gap[i], n - last[i])
	gapmin = [inf for i in range(n + 1)]
	for i in range(1, n + 1):
		if gap[i] == -1:
			continue
		gapmin[gap[i]] = min(gapmin[gap[i]], i)
	for i in range(1, n + 1):
		gapmin[i] = min(gapmin[i - 1], gapmin[i])
	for i in range(n + 1):
		if gapmin[i] == inf:
			gapmin[i] = -1
	pr(*gapmin[1:])


class PosIndexer:

	def __init__(self, nums):
		self.build(nums)

	def build(self, nums):
		self.pos_of_nums = [[] for i in range(len(nums) + 1)]
		for num in range(1, len(nums) + 1):
			self.pos_of_nums[num].append(0)
		for (index, num) in enumerate(nums):
			self.pos_of_nums[num].append(index + 1)
		for num in range(1, len(nums) + 1):
			self.pos_of_nums[num].append(len(nums) + 1)

	def find_max_range_for_num(self, num):
		return max([self.pos_of_nums[num][pos_index] - self.pos_of_nums[num][pos_index - 1] for pos_index in range(1, len(self.pos_of_nums[num]))])

def solve(nums):
	results = [-1 for i in range(len(nums) + 1)]
	pos_indexer = PosIndexer(nums)
	for num in range(1, len(nums) + 1):
		max_range_for_num = pos_indexer.find_max_range_for_num(num)
		if max_range_for_num <= len(nums) and results[max_range_for_num] == -1:
			results[max_range_for_num] = num
	for num in range(1, len(nums) + 1):
		if results[num - 1] != -1:
			if results[num] == -1:
				results[num] = results[num - 1]
			else:
				results[num] = min(results[num], results[num - 1])
	return results[1:]
for _ in range(int(input())):
	_ = int(input())
	nums = [int(token) for token in input().split()]
	result = solve(nums)
	print(*result)


import sys

def input():
	return sys.stdin.readline()
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	X = [0] * n
	Y = [-1] * n
	for i in range(n):
		a = A[i]
		Y[a - 1] = max(Y[a - 1], i - X[a - 1])
		X[a - 1] = i + 1
	ans = [-1] * n
	for i in range(n):
		if X[i]:
			Y[i] = max(Y[i], n - X[i])
			if ans[Y[i]] == -1:
				ans[Y[i]] = i + 1
	for i in range(1, n):
		if ans[i - 1] != -1:
			if ans[i] == -1:
				ans[i] = ans[i - 1]
			else:
				ans[i] = min(ans[i], ans[i - 1])
	print(*ans)


import sys
from sys import stdin, stdout
ipi = lambda : int(stdin.readline())
ipil = lambda : map(int, stdin.readline().split())
ipf = lambda : float(stdin.readline())
ipfl = lambda : map(float, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
outl = lambda x: print(*x)
T = ipi()
for _ in range(T):
	n = ipi()
	a = list(ipil())
	last_occur = dict()
	dis = dict()
	for i in range(n):
		tmp = a[i]
		lst_pos = last_occur.get(tmp)
		if lst_pos is None:
			last_occur[tmp] = i
			dis[tmp] = i + 1
		else:
			last_occur[tmp] = i
			dis[tmp] = max(dis[tmp], i - lst_pos)
	for (k, v) in last_occur.items():
		dis[k] = max(dis[k], n - v)
	ans = [-1] * n
	for (k, v) in dis.items():
		if ans[v - 1] == -1:
			ans[v - 1] = k
		else:
			ans[v - 1] = min(ans[v - 1], k)
	flag = -1
	for i in range(n):
		if ans[i] != -1:
			if flag != -1:
				ans[i] = min(flag, ans[i])
			flag = ans[i]
		else:
			ans[i] = flag
	outl(ans)


import io
import os
from collections import Counter, defaultdict, deque
inf = float('inf')

def solve(N, A):
	valToIndices = defaultdict(list)
	for (i, x) in enumerate(A):
		valToIndices[x].append(i)
	valToGap = {}
	for (x, indices) in valToIndices.items():
		maxGap = max(indices[0] + 1, N - indices[-1])
		for (i, j) in zip(indices, indices[1:]):
			maxGap = max(maxGap, j - i)
		valToGap[x] = maxGap
	best = [inf] * (N + 1)
	for (k, v) in valToGap.items():
		best[v] = min(best[v], k)
	for (k, b) in enumerate(best):
		if k >= 1:
			best[k] = min(best[k - 1], b)
	ans = [-1 if x == inf else x for x in best][1:]
	return ' '.join(map(str, ans))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = defaultdict(list)
	l = []
	for i in range(n):
		d[arr[i]].append(i)
	for i in d:
		ma = d[i][0] + 1
		c = d[i][0]
		for j in d[i][1:]:
			ma = max(ma, j - c)
			c = j
		ma = max(ma, n - d[i][-1])
		l.append([ma, i])
	l.append([n + 1, 100000000000])
	ans = [-1] * n
	l.sort(key=lambda x: (x[0], -x[1]))
	mi = 10000000000000
	for i in range(len(l) - 1):
		if l[i + 1][0] == l[i][0]:
			continue
		mi = min(mi, l[i][1])
		for j in range(l[i][0], l[i + 1][0]):
			ans[j - 1] = mi
	print(*ans)


import sys, math, cmath, time, collections
start_time = time.time()

def solve():
	n = inp()
	a = inlt()
	q = dict()
	qq = [-1] * len(a)
	for i in range(len(a)):
		if a[i] in q:
			q[a[i]].append(i)
		else:
			q[a[i]] = [-1, i]
	q = collections.OrderedDict(sorted(q.items()))
	for i in q:
		q[i].append(len(a))
		w = 0
		for j in range(1, len(q[i])):
			w = max(w, q[i][j] - q[i][j - 1])
		qw = w - 1
		if qq[qw] == -1:
			qq[qw] = i
	ww = -1
	for i in range(len(qq)):
		if qq[i] != -1:
			if ww == -1:
				ww = qq[i]
			qq[i] = min(ww, qq[i])
			ww = qq[i]
		else:
			qq[i] = ww
	sys.stdout.write(' '.join(map(str, qq)) + '\n')

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

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

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

def insr():
	return input().strip()

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

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	import io, os
	input = sys.stdin.readline
main()


import typing
import sys
import math
import collections
import bisect
import itertools
import fractions
import copy
import heapq
import decimal
import queue
INF = 10 ** 20
MOD = 998244353

def ni():
	return int(sys.stdin.readline())

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

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

def main():
	t = ni()
	for _ in range(t):
		n = ni()
		a = na()
		res = [-1 for _ in range(n)]
		latest = [-1 for _ in range(n)]
		for (i, ai) in enumerate(a):
			tai = ai - 1
			tmp = i - latest[tai]
			res[tai] = max(res[tai], tmp)
			latest[tai] = i
		for i in range(n):
			if res[i] == -1:
				continue
			res[i] = max(res[i], n - latest[i])
		ans = [INF for _ in range(n)]
		for i in range(n):
			if res[i] == -1:
				continue
			ans[res[i] - 1] = min(ans[res[i] - 1], i + 1)
		for i in range(1, n):
			if ans[i] > ans[i - 1]:
				ans[i] = ans[i - 1]
		for i in range(n):
			if ans[i] == INF:
				ans[i] = -1
		print(*ans, sep=' ')
main()


T = int(input())
for _ in range(T):
	n = int(input())
	a = [int(x) - 1 for x in input().split()]
	prev = [-1 for _ in range(n)]
	val = [1 for _ in range(n)]
	for (i, x) in enumerate(a):
		delta = i - prev[x]
		val[x] = max(val[x], delta)
		prev[x] = i
	for i in range(n):
		val[i] = max(val[i], n - prev[i])
	ans = [-1 for _ in range(n + 1)]
	r = n + 1
	for i in range(n):
		if val[i] < r:
			for j in range(val[i], r):
				ans[j] = i + 1
			r = val[i]
	print(' '.join([str(x) for x in ans[1:]]))


import math
T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	d = False
	m = [0] * (n + 1)
	lm = [-1] * (n + 1)
	app = set(a)
	for i in range(n):
		m[a[i]] = max(m[a[i]], i - lm[a[i]])
		lm[a[i]] = i
	for i in app:
		if m[i] != 0:
			m[i] = max(m[i], n - lm[i])
	ans = [-1] * n
	for i in app:
		if ans[m[i] - 1] != -1:
			ans[m[i] - 1] = min(ans[m[i] - 1], i)
		else:
			ans[m[i] - 1] = i
	nn = 1
	mmm = n + 1
	for i in range(n):
		if ans[i] != -1:
			nn = 0
		if nn:
			ans[i] = '-1'
		else:
			if ans[i] != -1:
				mmm = min(mmm, ans[i])
			ans[i] = str(mmm)
	print(' '.join(ans))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ls = [[] for i in range(n + 5)]
	for i in range(n):
		ls[a[i]].append(i)
	ans = [-1] * n
	mx = n
	for i in range(1, n + 1):
		n1 = len(ls[i])
		if n1 > 0:
			cnt = ls[i][0]
			for j in range(1, n1):
				cnt = max(cnt, ls[i][j] - 1 - ls[i][j - 1])
			cnt = max(cnt, n - ls[i][-1] - 1)
			for j in range(cnt, mx):
				ans[j] = i
			mx = min(mx, cnt)
	for i in ans:
		print(i, end=' ')
	print()


import math
import os
from io import BytesIO, IOBase
import sys
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 defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	last_seen = defaultdict(int)
	max_dist = {}
	for (idx, val) in enumerate(a):
		if val in max_dist:
			max_dist[val] = max(max_dist[val], idx - last_seen[val])
		else:
			max_dist[val] = idx + 1
		last_seen[val] = idx
	for (val, idx) in last_seen.items():
		max_dist[val] = max(max_dist[val], n - idx)
	results = {}
	for (val, md) in max_dist.items():
		if md in results:
			results[md] = min(val, results[md])
		else:
			results[md] = val
	output = []
	best = -1
	for i in range(1, n + 1):
		if i in results:
			if best == -1:
				best = results[i]
			else:
				best = min(results[i], best)
		output.append(best)
	print(' '.join([str(x) for x in output]))


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	g = [[-1] for _ in range(n + 1)]
	for i in range(n):
		g[s[i]].append(i)
	inf = 10 ** 10
	ans = [-1] * n
	lstunused = n
	for i in range(1, n + 1):
		g[i].append(n)
		mx = 0
		for j in range(1, len(g[i])):
			mx = max(mx, g[i][j] - g[i][j - 1] - 1)
		for j in range(mx, lstunused):
			ans[j] = i
		lstunused = min(lstunused, mx)
	print(*ans)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

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

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		ind = [[] for i in range(n)]
		for i in range(n):
			ind[a[i] - 1].append(i)
		freq = [int(100000000.0)] * n
		for i in range(n):
			if ind[i] == []:
				continue
			mx = 0
			start = -1
			for j in range(len(ind[i])):
				mx = max(mx, ind[i][j] - start)
				start = ind[i][j]
			mx = max(mx, n - start)
			freq[mx - 1] = min(freq[mx - 1], i + 1)
		for i in range(n):
			if freq[i] < int(100000000.0):
				start = i
				break
			freq[i] = -1
		m = 100000000.0
		for i in range(start, n):
			m = min(m, freq[i])
			freq[i] = m
		print(*freq)
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout
from collections import deque
import bisect
R = lambda : stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(' '))) if f else list(R().split(' '))
output = lambda x: stdout.write(str(x) + '\n')
output_list = lambda x: output(' '.join(map(str, x)))
T = int(input())
for _ in range(T):
	n = int(R())
	l = RL(int)
	ind = [0] * (n + 1)
	max_diff = [0] * (n + 1)
	max_diff[0] = 10 ** 5
	for i in range(1, n + 1):
		max_diff[l[i - 1]] = max(max_diff[l[i - 1]], i - ind[l[i - 1]])
		ind[l[i - 1]] = i
	for i in range(1, n + 1):
		max_diff[l[i - 1]] = max(max_diff[l[i - 1]], n + 1 - ind[l[i - 1]])
	ans = [-1] * n
	for i in range(n):
		if max_diff[i + 1] != 0:
			if ans[max_diff[i + 1] - 1] == -1:
				ans[max_diff[i + 1] - 1] = i + 1
	ini = -1
	for i in range(n):
		if ans[i] == -1:
			ans[i] = ini
		elif ans[i] != ini:
			ini = ans[i]
	for i in range(n):
		if ans[i] != -1:
			mi = ans[i]
			break
	for i in range(1, n):
		if ans[i] != -1:
			if ans[i] > mi:
				ans[i] = mi
			else:
				mi = ans[i]
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if lis[i] not in d:
			d[lis[i]] = []
			d[lis[i]].append(i)
		else:
			d[lis[i]].append(i)
	for i in d:
		d[i].append(n)
	ans = [1000000000000] * n
	for i in d:
		pre = -1
		mx = 0
		for j in d[i]:
			mx = max(mx, j - pre)
			pre = j
		if ans[mx - 1] == -1:
			ans[mx - 1] = i
		else:
			ans[mx - 1] = min(ans[mx - 1], i)
	prev = 1000000000000
	for i in range(n):
		ans[i] = min(ans[i], prev)
		prev = min(ans[i], prev)
	for i in range(n):
		if ans[i] == 1000000000000:
			ans[i] = -1
	print(*ans)


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

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

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

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

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

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

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	n = II()
	a = L()
	dist = {}
	last = {}
	for i in range(n):
		x = a[i]
		if dist.get(x, -1) == -1:
			dist[x] = i + 1
			last[x] = i
		else:
			dist[x] = max(dist[x], i - last[x])
			last[x] = i
	for ele in dist:
		dist[ele] = max(dist[ele], n - last[ele])
	ulta = {}
	for ele in dist:
		ulta[dist[ele]] = min(ele, ulta.get(dist[ele], 2 * n))
	li = [2 * n] * (n + 1)
	for ele in ulta:
		li[ele] = ulta[ele]
	for i in range(1, n + 1):
		li[i] = min(li[i - 1], li[i])
	for i in range(1, n + 1):
		if li[i] == 2 * n:
			print(-1, end=' ')
		else:
			print(li[i], end=' ')
	print()
	return
t = II()
for i in range(t):
	solve()


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pre = {}
	l = [0] * n
	for j in range(n - 1, -1, -1):
		l[j] = pre.get(a[j], n) - j
		pre[a[j]] = j
	pre = {}
	d = {}
	l2 = [0] * n
	for j in range(n):
		l2[j] = j - pre.get(a[j], -1)
		pre[a[j]] = j
		d[a[j]] = 0
	for j in range(n):
		d[a[j]] = max(d[a[j]], l[j], l2[j])
	l = [10 ** 6] * n
	for j in d:
		l[d[j] - 1] = min(l[d[j] - 1], j)
	if l[0] == 10 ** 6:
		print(-1, end=' ')
	else:
		print(l[0], end=' ')
	for j in range(1, n):
		l[j] = min(l[j], l[j - 1])
		if l[j] == 10 ** 6:
			print(-1, end=' ')
		else:
			print(l[j], end=' ')
	print()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

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

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

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 ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def chck(mid, ind, n):
	if ind[0] > mid - 1:
		return False
	for i in range(1, len(ind)):
		if ind[i] - ind[i - 1] > mid:
			return False
	curr = ind[len(ind) - 1]
	if n - curr > mid:
		return False
	return True

def solve(case):
	n = int(inp())
	a = lis()
	pos = {}
	for i in range(n):
		if a[i] in pos:
			pos[a[i]].append(i)
		else:
			pos[a[i]] = [i]
	arr = {}
	for i in pos:
		ind = pos[i]
		lo = 1
		hi = n
		ans = n
		while lo <= hi:
			mid = (lo + hi) // 2
			if chck(mid, ind, n):
				ans = min(ans, mid)
				hi = mid - 1
			else:
				lo = mid + 1
		arr[i] = ans
	ans = [0] * (n + 1)
	sl = []
	for i in pos:
		sl.append(i)
	sl = sorted(sl)
	curr = n + 1
	for i in range(len(sl)):
		if arr[sl[i]] < curr:
			for j in range(arr[sl[i]], curr):
				ans[j] = sl[i]
			curr = arr[sl[i]]
		else:
			continue
	for i in range(len(ans)):
		if ans[i] == 0:
			ans[i] = -1
	print(' '.join((str(ans[i]) for i in range(1, len(ans)))))
testcase(int(inp()))


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	(f, last, ans) = ([0] * (n + 1), [-1] * (n + 1), [-1] * (n + 1))
	for (i, a) in enumerate(A):
		f[a] = max(f[a], i - last[a])
		last[a] = i
	for a in range(1, n + 1):
		f[a] = max(f[a], n - last[a])
	for a in range(1, n + 1):
		i = f[a]
		while i <= n and ans[i] == -1:
			ans[i] = a
			i += 1
	ans = ans[1:]
	print(*ans)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	index = [[0] for _ in range(n + 1)]
	ans = [float('inf')] * (n + 1)
	for i in range(n):
		index[a[i]].append(i + 1)
	for j in range(1, n + 1):
		if len(index[j]) == 1:
			continue
		min_idx = -1
		for k in range(len(index[j]) - 1):
			min_idx = max(index[j][k + 1] - index[j][k], min_idx)
		min_idx = max(min_idx, index[j][1], n - index[j][-1] + 1)
		ans[min_idx] = min(j, ans[min_idx])
	ans2 = [float('inf')]
	for k in range(1, n + 1):
		ans2.append(min(ans2[k - 1], ans[k]))
	for k in range(1, n + 1):
		if ans2[k] == float('inf'):
			ans2[k] = -1
	print(*ans2[1:])


INF = 10 ** 15
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {i: 0 for i in arr}
	last = {i: -1 for i in arr}
	for i in range(n):
		if last[arr[i]] == -1:
			d[arr[i]] = max(d[arr[i]], i + 1)
		else:
			d[arr[i]] = max(d[arr[i]], i - last[arr[i]])
		last[arr[i]] = i
	for i in list(last.keys()):
		d[i] = max(d[i], n - last[i])
	d2 = {}
	for (k, v) in list(d.items()):
		if v not in d2:
			d2[v] = INF
		d2[v] = min(d2[v], k)
	ans = [INF] * n
	for i in range(1, n + 1):
		can = INF
		if i != 1:
			can = ans[i - 2]
		if i in list(d2.keys()):
			can = min(can, d2[i])
		ans[i - 1] = can
	for i in range(n):
		if ans[i] == INF:
			ans[i] = -1
	print(*ans)


import sys
from copy import *
from bisect import *
from itertools import permutations as prm, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	if len(set(a)) == 1:
		print(*[a[0]] * n)
		continue
	dif = {}
	p = set()
	for i in range(n):
		if a[i] not in dif:
			dif[a[i]] = [-1]
		dif[a[i]].append(i)
		p.add(a[i])
	p = list(p)
	p.sort()
	lo = n + 1
	ans = [-1] * (n + 1)
	for i in p:
		dif[i].append(n)
		maxi = 0
		for j in range(1, len(dif[i])):
			maxi = max(maxi, dif[i][j] - dif[i][j - 1])
		for j in range(maxi, lo):
			ans[j] = i
		lo = min(lo, maxi)
	print(*ans[1:])


import os, sys
from collections import defaultdict, Counter
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = [int(x) for x in input().split()]
		x = defaultdict(lambda : [])
		p = defaultdict(lambda : -1)
		q = defaultdict(lambda : -1)
		for i in range(n):
			x[a[i]].append(i - p[a[i]])
			p[a[i]] = i
		an = 100000000
		for i in x:
			z = max(max(x[i]), n - p[i])
			if q[z] != -1:
				q[z] = min(q[z], i)
			else:
				q[z] = i
		w = -1
		for j in range(1, n + 1):
			if q[j] != -1:
				if w != -1:
					w = min(q[j], w)
				else:
					w = q[j]
			print(w, end=' ')
		print()
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 sys, functools, collections, bisect, math, heapq
input = sys.stdin.readline
sys.setrecursionlimit(200000)
mod = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	res = [-1] * n
	d = collections.defaultdict(list)
	for i in range(n):
		d[arr[i]].append(i)
	for i in d:
		ans = d[i][0] + 1
		for j in range(1, len(d[i])):
			x = d[i][j] - d[i][j - 1]
			if x > ans:
				ans = x
		x = n - d[i][-1]
		if x > ans:
			ans = x
		if res[ans - 1] == -1:
			res[ans - 1] = i
		elif res[ans - 1] > i:
			res[ans - 1] = i
	for i in range(1, n):
		if res[i] == -1 or res[i] > res[i - 1] > 0:
			res[i] = res[i - 1]
	print(' '.join((str(i) for i in res)))


from collections import defaultdict

def read_ints():
	return map(int, input().split())
(t_n,) = read_ints()
for i_t in range(t_n):
	(n,) = read_ints()
	a_seq = tuple(read_ints())
	assert len(a_seq) == n
	indices_by_value = defaultdict(list)
	for (i, a) in enumerate(a_seq):
		indices_by_value[a].append(i)
	min_k_by_value = dict()
	for (value, indices) in indices_by_value.items():
		indices.sort()
		max_k_need = max(indices[0] + 1, n - indices[-1])
		for i_i in range(len(indices) - 1):
			k_need = indices[i_i + 1] - indices[i_i]
			if k_need > max_k_need:
				max_k_need = k_need
		min_k_by_value[value] = max_k_need
	result = [-1] * n
	for (value, k) in min_k_by_value.items():
		i = k - 1
		if result[i] == -1 or result[i] > value:
			result[i] = value
	for i in range(1, n):
		if result[i] == -1 or (result[i - 1] != -1 and result[i] > result[i - 1]):
			result[i] = result[i - 1]
	print(*result)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	dic1 = defaultdict(int)
	dic2 = {}
	lis = list(map(int, input().split()))
	lastocc = {}
	for i in range(len(lis)):
		lastocc[lis[i]] = i
	for i in range(len(lis)):
		if lis[i] not in dic1:
			dic1[lis[i]] = i
			dic2[lis[i]] = i + 1
		else:
			if dic2[lis[i]] < i - dic1[lis[i]]:
				dic2[lis[i]] = i - dic1[lis[i]]
			dic1[lis[i]] = i
	for i in range(len(lis)):
		if dic2[lis[i]] == -1:
			dic2[lis[i]] = max(i + 1, len(lis) - i)
		else:
			dic2[lis[i]] = max(dic2[lis[i]], len(lis) - lastocc[lis[i]])
	dic3 = defaultdict(list)
	for i in dic2:
		dic3[dic2[i]].append(i)
	lis2 = []
	for i in dic3:
		lis2.append(i)
	min1 = float('Inf')
	output = []
	for i in range(1, n + 1):
		if i in dic3:
			min1 = min(min1, min(dic3[i]))
		if min1 == float('Inf'):
			output.append(-1)
		else:
			output.append(min1)
	for i in output:
		print(i, end=' ')
	print()


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(x) - 1 for x in input().split()]
	last_occ = [-1 for _ in range(n)]
	max_dist = [float('-inf') for _ in range(n)]
	for (i, x) in enumerate(a):
		max_dist[x] = max(max_dist[x], i - last_occ[x])
		last_occ[x] = i
	for x in a:
		max_dist[x] = max(max_dist[x], n - last_occ[x])
	inverted = [float('inf') for _ in range(n)]
	for x in a:
		inverted[max_dist[x] - 1] = min(inverted[max_dist[x] - 1], x)
	best = float('inf')
	for x in inverted:
		if x != float('inf'):
			best = min(x, best)
		if best == float('inf'):
			print(-1, end=' ')
		else:
			print(best + 1, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	e = [-1 for i in range(n)]
	for i in range(n):
		if a[i] in d:
			d[a[i]].append(i)
		else:
			d[a[i]] = [-1, i]
	for i in sorted(d):
		d[i].append(n)
		mx = 0
		for j in range(len(d[i]) - 1):
			mx = max(d[i][j + 1] - d[i][j] - 1, mx)
		for k in range(mx, n):
			if e[k] != -1:
				break
			e[k] = i
	print(*e)


import sys
input = sys.stdin.readline
from collections import defaultdict
(T,) = map(int, input().split())
for _ in range(T):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	pd = defaultdict(int)
	d = defaultdict(int)
	for i in range(N):
		x = X[i]
		d[x] = max(d[x], i + 1 - pd[x])
		pd[x] = i + 1
	rv = defaultdict(lambda : 10 ** 18)
	for key in d:
		d[key] = max(d[key], N + 1 - pd[key])
		rv[d[key]] = min(rv[d[key]], key)
	R = [-1] * N
	mn = 10 ** 18
	for i in range(N):
		if i + 1 in rv:
			mn = min(mn, rv[i + 1])
		if mn != 10 ** 18:
			R[i] = mn
	print(*R)


from collections import defaultdict
T = int(input())
for t in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	els = sorted(set(A))
	pos = defaultdict(list)
	for (i, el) in enumerate(A):
		pos[el].append(i)
	DMAX = {}
	for el in pos.keys():
		dmax = -1
		arr = [-1] + sorted(pos[el]) + [N]
		for i in range(1, len(arr)):
			dmax = max(dmax, arr[i] - arr[i - 1])
		DMAX[el] = dmax
	ci = 0
	answer = []
	for i in range(N - 1, -1, -1):
		while ci < len(els) and DMAX[els[ci]] > i + 1:
			ci += 1
		if ci >= len(els):
			answer.append(-1)
		else:
			answer.append(els[ci])
	print(' '.join(map(str, answer[::-1])))


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	st = 0
	end = n - 1
	ma1 = []
	d = defaultdict(list)
	for i in range(n):
		d[l[i]].append(i)
	u = []
	for i in d:
		m = 0
		d[i].append(n)
		d[i].append(-1)
		d[i].sort()
		for j in range(1, len(d[i])):
			m = max(m, d[i][j] - d[i][j - 1] - 1)
		ma1.append(m)
		u.append(i)
	u = sort_list(u, ma1)
	ma1.sort()
	ans = [-1] * n
	s = [0] * n
	s[0] = u[0]
	for i in range(1, len(u)):
		s[i] = min(s[i - 1], u[i])
	for i in range(n):
		diff = i
		ind = binarySearchCount(ma1, len(ma1), diff)
		if ind != 0:
			ans[i] = s[ind - 1]
	print(*ans)


import sys
import math
input = sys.stdin.readline

def inInt():
	return int(input())

def inStr():
	return input().strip('\n')

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

def inSList():
	return input().split()

def solve(n, l):
	ret = []
	m = {}
	for x in range(n):
		if l[x] in m:
			m[l[x]].append(x)
		else:
			m[l[x]] = [x]
	score = {}
	for (k, v) in m.items():
		new_v = [-1] + v + [n]
		diff = 0
		for x in range(1, len(new_v)):
			diff = max(diff, new_v[x] - new_v[x - 1])
		score[k] = diff
	index = {}
	for (k, v) in score.items():
		if v in index:
			index[v] = min(index[v], k)
		else:
			index[v] = k
	index = sorted(index.items())
	table = [index[0]]
	for i in range(1, len(index)):
		table.append((index[i][0], min(index[i][1], table[i - 1][1])))
	table = [(0, -1)] + table
	b = 0
	for k in range(1, n + 1):
		if b + 1 < len(table) and k < table[b + 1][0]:
			print(table[b][1], end=' ')
		else:
			if b + 1 < len(table):
				b += 1
			print(table[b][1], end=' ')
	print()
tasks = inInt()
for t in range(tasks):
	n = inInt()
	l = inIList()
	solve(n, l)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	bckt = [-1] * (n + 1)
	last_appearance = [-1] * (n + 1)
	min_subset = [-1] * (n + 1)
	for i in range(n):
		min_subset[a[i]] = max(min_subset[a[i]], i - last_appearance[a[i]])
		last_appearance[a[i]] = i
	for i in range(1, n + 1):
		if last_appearance[i] != -1:
			min_subset[i] = max(min_subset[i], n - last_appearance[i])
	inv = [10 ** 9] * (n + 1)
	for i in range(1, 1 + n):
		if min_subset[i] != -1:
			inv[min_subset[i]] = min(inv[min_subset[i]], i)
	current = inv[0]
	for i in range(1, n + 1):
		if inv[i] < current:
			current = inv[i]
		inv[i] = current
	for i in range(len(inv)):
		if inv[i] == 10 ** 9:
			inv[i] = -1
	print(*inv[1:])


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for (i, v) in enumerate(a):
		if v in d:
			d[v]['max'] = max(d[v]['max'], i - d[v]['pos'])
			d[v]['pos'] = i
		else:
			d[v] = {'max': i + 1, 'pos': i}
	for v in d:
		d[v]['max'] = max(d[v]['max'], n - d[v]['pos'])
	ans = {}
	for v in d:
		m = d[v]['max']
		if m in ans:
			if v < ans[m]:
				ans[m] = v
		else:
			ans[m] = v
	prev = -1
	for i in range(1, n + 1):
		cur = ans.get(i, -1)
		if cur == -1:
			res = prev
		elif prev == -1:
			res = cur
		else:
			res = min(cur, prev)
		prev = res
		print(res, end=' ')
	print()
t = int(input())
for _ in range(t):
	solve()


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	dt = defaultdict(list)
	for (i, v) in enumerate(arr):
		dt[v].append(i)
	ret = [-1 for _ in range(n + 2)]
	for i in range(1, n + 1):
		if i not in dt:
			continue
		tmp = dt[i][0] + 1
		for idx in range(1, len(dt[i])):
			tmp = max(tmp, dt[i][idx] - dt[i][idx - 1])
		tmp = max(tmp, n - dt[i][-1])
		if ret[tmp] == -1:
			ret[tmp] = i
	for i in range(2, n + 1):
		if ret[i - 1] == -1:
			continue
		if ret[i] == -1 or ret[i] > ret[i - 1]:
			ret[i] = ret[i - 1]
	print(' '.join(map(str, ret[1:n + 1])))


def solve(n):
	s = list(map(int, input().split()))
	ind = [[] for _ in range(n + 1)]
	for i in range(n):
		ind[s[i]].append(i)
	ans = [1000000] * (n + 1)
	for i in range(1, n + 1):
		k = 0
		length = len(ind[i])
		if length == 0:
			continue
		for j in range(length - 1):
			k = max(ind[i][j + 1] - ind[i][j], k)
		k = max(n - ind[i][-1], ind[i][0] + 1, k)
		for j in range(k, n + 1):
			if ans[j] <= 300000:
				break
			ans[j] = i
	for i in range(1, n + 1):
		if ans[i] > 300000:
			print(-1, end=' ')
		else:
			print(ans[i], end=' ')
	print()
for _ in range(int(input())):
	n = int(input())
	solve(n)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

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

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def pow(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
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a
from collections import defaultdict

def solve():
	n = int(input())
	ar = lis()
	temp = [[0] for _ in range(n + 1)]
	for i in range(n):
		temp[ar[i]].append(i + 1)
	for i in range(1, n + 1):
		temp[i].append(n + 1)
	new_temp = [[] for _ in range(n + 1)]
	for i in range(1, n + 1):
		for j in range(1, len(temp[i])):
			new_temp[i].append(temp[i][j] - temp[i][j - 1])
	ans = [-1] * (n + 1)
	for i in range(1, n + 1):
		t = max(new_temp[i])
		for j in range(t, n + 1):
			if ans[j] != -1:
				break
			ans[j] = i
	print(*ans[1:])
testcase(int(inp()))


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(list)
	for i in range(n):
		if a[i] not in d:
			d[a[i]].append(-1)
			d[a[i]].append(i)
		else:
			d[a[i]].append(i)
	s = sorted(d.keys())
	ans = [-1] * (n + 1)
	for el in s:
		mx = 0
		d[el].append(n)
		for i in range(1, len(d[el])):
			mx = max(mx, d[el][i] - d[el][i - 1])
		if ans[mx] == -1:
			ans[mx] = el
		else:
			ans[mx] = min(ans[mx], el)
	f = -1
	for i in range(1, n + 1):
		if ans[i] == -1:
			ans[i] = f
		elif f == -1:
			f = ans[i]
		else:
			ans[i] = min(ans[i], f)
			f = ans[i]
	print(*ans[1:])


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	n = int(input())
	ans = [-1] * (n + 1)
	arr = list(map(int, input().split()))
	val_with_index = []
	for i in range(0, n):
		val_with_index.append((arr[i], i))
	val_with_index.sort()
	positions = []
	for i in range(0, n):
		positions.append(val_with_index[i][1])
		if i == n - 1 or (i + 1 < n and val_with_index[i][0] != val_with_index[i + 1][0]):
			positions.append(n)
			max_of_min_segment_len = positions[0] + 1
			for j in range(1, len(positions)):
				max_of_min_segment_len = max(max_of_min_segment_len, positions[j] - positions[j - 1])
			for k in range(max_of_min_segment_len, n + 1):
				if ans[k] == -1:
					ans[k] = val_with_index[i][0]
				else:
					break
			positions = []
	print(' '.join(map(str, ans[1:])))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	dict = {}
	for i in range(n):
		if arr[i] in dict:
			dict[arr[i]].append(i)
		else:
			dict[arr[i]] = [-1, i]
	for i in dict:
		dict[i].append(n)
	out = [-1 for x in range(n)]
	for i in sorted(dict.keys()):
		m = -1
		for j in range(len(dict[i]) - 1):
			m = max(m, dict[i][j + 1] - dict[i][j] - 1)
		for j in range(m, n):
			if out[j] != -1:
				break
			out[j] = i
	print(*out)


from sys import stdin
from collections import defaultdict
t = int(stdin.readline())
while t:
	seen = defaultdict(list)
	n = int(stdin.readline())
	a = [int(x) for x in stdin.readline().split()]
	best = ()
	for i in range(n):
		seen[a[i]].append(i + 1)
	out = [10 ** 10] * n
	distances = defaultdict(list)
	for key in list(seen.keys()):
		hue = seen[key]
		big = -1
		for i in range(1, len(hue)):
			big = max(hue[i] - hue[i - 1] - 1, big)
		big = max(n - hue[-1], big)
		big = max(hue[0] - 1, big)
		out[big] = min(out[big], key)
	for i in range(1, n):
		out[i] = min(out[i], out[i - 1])
	print(' '.join([str(x) if x != 10 ** 10 else str(-1) for x in out]))
	t -= 1


t = input()
t = int(t)

def solve(n, arr):
	ans = [float('inf') for _ in range(n)]
	pos = {}
	dist = {}
	for i in range(n):
		pos[arr[i]] = 0
		dist[arr[i]] = 0
	for i in range(n):
		dis = i + 1 - pos[arr[i]]
		dist[arr[i]] = max(dis, dist[arr[i]])
		pos[arr[i]] = i + 1
	for i in range(n):
		dis = n + 1 - pos[arr[i]]
		dist[arr[i]] = max(dis, dist[arr[i]])
	for i in range(n):
		if i + 1 in dist and i + 1 < ans[dist[i + 1] - 1]:
			ans[dist[i + 1] - 1] = i + 1
	seed = ans[0]
	for i in range(1, n):
		if ans[i] < seed:
			seed = ans[i]
		else:
			ans[i] = seed
	for i in range(n):
		if ans[i] == float('inf'):
			ans[i] = -1
	print(*ans)
for i in range(t):
	n = input()
	n = int(n)
	arr = list(map(int, input().split()))
	solve(n, arr)


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	count = Counter(arr)
	if len(count) == n:
		arr.sort()
		ans = [-1] * n
		j = (n + 1) // 2 - 1
		for i in range(n // 2, n):
			ans[i] = arr[j]
			j -= 1
		print(*ans)
		continue
	if len(count) == 1:
		print(*arr)
		continue
	ind = defaultdict(list)
	for i in range(n):
		ind[arr[i]].append(i + 1)
	ind = sorted(ind.items(), key=lambda x: (-len(x[1]), x[0]))
	ans = [-1] * n
	mapka = {i: float('inf') for i in range(1, n + 1)}
	for (k, v) in ind:
		maxgap = max(v[0], n - v[-1] + 1)
		for i in range(len(v) - 1):
			maxgap = max(maxgap, v[i + 1] - v[i])
		mapka[maxgap] = min(k, mapka[maxgap])
	prev = float('inf')
	for (k, v) in mapka.items():
		if v != float('inf'):
			prev = min(prev, v)
			ans[k - 1] = prev
		elif prev == float('inf'):
			ans[k - 1] = -1
		else:
			ans[k - 1] = prev
	ans[n - 1] = min(arr)
	print(*ans)


from collections import defaultdict

def solve(arr):
	n = len(arr)
	lastIndex = defaultdict(lambda : int(-1))
	maxSpan = defaultdict(int)
	for i in range(n):
		maxSpan[arr[i]] = max(maxSpan[arr[i]], i - lastIndex[arr[i]])
		lastIndex[arr[i]] = i
	minPerMaxSpan = defaultdict(lambda : float(float('inf')))
	for (key, val) in maxSpan.items():
		val = max(val, n - lastIndex[key])
		minPerMaxSpan[val] = min(minPerMaxSpan[val], key)
	lastMin = float('inf')
	isSet = False
	ret = []
	for i in range(1, n + 1):
		if i in minPerMaxSpan:
			ret.append(min(lastMin, minPerMaxSpan[i]))
			lastMin = min(minPerMaxSpan[i], lastMin)
			isSet = True
		elif isSet:
			ret.append(lastMin)
		else:
			ret.append(-1)
	return ret
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = solve(arr)
	print(*ans)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	min_subsegment = [-1] * (n + 1)
	last_seen = [-1] * (n + 1)
	for i in range(n):
		min_subsegment[a[i]] = max(min_subsegment[a[i]], i - last_seen[a[i]])
		last_seen[a[i]] = i
	for i in range(1, 1 + n):
		min_subsegment[i] = max(min_subsegment[i], n - last_seen[i])
	ans = [10 ** 9] * (n + 1)
	for i in range(1, 1 + n):
		if min_subsegment[i] != n + 1:
			ans[min_subsegment[i]] = min(ans[min_subsegment[i]], i)
	mn = ans[0]
	for i in range(1, 1 + n):
		mn = min(mn, ans[i])
		ans[i] = mn
	for i in range(1, 1 + n):
		if ans[i] == 10 ** 9:
			ans[i] = -1
	print(*ans[1:])


from collections import defaultdict, Counter

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	indices = defaultdict(lambda : [0])
	for i in range(n):
		indices[arr[i]].append(i + 1)
	distances = defaultdict(lambda : [])
	for key in indices.keys():
		j = indices[key][0]
		for i in range(1, len(indices[key])):
			distances[key].append(indices[key][i] - j)
			j = indices[key][i]
		distances[key].append(n + 1 - j)
		distances[key].sort(reverse=True)
	keys = sorted(list(distances.keys()))
	ans = [-1] * (n + 2)
	for key in keys:
		j = distances[key][0]
		while j <= n:
			if ans[j] != -1:
				break
			ans[j] = key
			j += 1
	print(*ans[1:n + 1])

def main():
	for case in range(int(input())):
		solve()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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
from sys import stdin, stdout

class Input:

	def __init__(self):
		self.lines = stdin.readlines()
		self.idx = 0

	def line(self):
		try:
			return self.lines[self.idx].strip()
		finally:
			self.idx += 1

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.idx < len(self.lines):
			yield self

def problem_solver():

	def solver(inpt):
		MASK = (1 << 19) - 1
		(n,) = inpt.array()
		a = inpt.array()
		b = [a[i] << 19 | i for i in range(n)]
		b.sort()
		c = [-1 for i in range(n)]
		top = n
		le = 0
		ri = 0
		while le < n:
			p = -1
			d = 0
			while ri < n:
				if b[le] >> 19 < b[ri] >> 19:
					break
				q = b[ri] & MASK
				d = max(d, q - p)
				p = q
				ri += 1
			d = max(d, n - p)
			while top >= d:
				c[top - 1] = b[le] >> 19
				top -= 1
			le = ri
		print(*c)
	return solver
try:
	solver = problem_solver()
	for tc in Input().known_tests():
		solver(tc)
except Exception as e:
	import traceback
	traceback.print_exc(file=stdout)


def sol(a, n):
	pos = [-1] * n
	dist = [-1] * n
	for i in range(len(a)):
		c = a[i] - 1
		dist[c] = max(dist[c], i - pos[c] - 1)
		pos[c] = i
	for i in range(n):
		if dist[i] != -1:
			dist[i] = max(dist[i], n - pos[i] - 1)
	re = [-1] * n
	for i in range(n):
		if dist[i] != -1:
			begin = dist[i]
			while begin < n and re[begin] == -1:
				re[begin] = i + 1
				begin += 1
	return re
tc = int(input())
for _ in range(tc):
	n = int(input())
	a = list(map(lambda x: int(x), input().split(' ')))
	re = sol(a, n)
	print(*re, sep=' ')


from collections import defaultdict

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(list)
	for (i, v) in enumerate(a):
		d[v].append(i + 1)
	V = list(d.keys())
	V.sort()
	mint = [n + 1] * (n + 1)
	for v in V:
		L = d[v]
		sub_max = L[0]
		L.append(n + 1)
		for i in range(len(L) - 1):
			sub_max = max(sub_max, L[i + 1] - L[i])
		mint[sub_max] = min(v, mint[sub_max])
	for i in range(1, n + 1):
		mint[i] = min(mint[i], mint[i - 1])
	res = []
	for i in range(1, n + 1):
		if mint[i] == n + 1:
			res.append(-1)
		else:
			res.append(mint[i])
	print(*res)
	return

def main():
	T = int(input())
	for i in range(T):
		solve()
	return
main()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
from collections import defaultdict

def gift():
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		lis = [0] * (n + 1)
		md = [float('-inf')] * (n + 1)
		for i in range(n):
			md[a[i]] = max(md[a[i]], i + 1 - lis[a[i]])
			lis[a[i]] = i + 1
		for i in range(n + 1):
			md[i] = max(md[i], n + 1 - lis[i])
		itr = n - 1
		ans = [-1] * n
		for i in range(1, n + 1):
			while md[i] <= itr + 1:
				ans[itr] = i
				itr -= 1
		yield ' '.join((str(x) for x in ans))
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())
for j in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = [-1 for j in range(n + 3)]
	d = {}
	la = l[-1]
	f = l[0]
	for j in range(n):
		if l[j] not in d:
			d[l[j]] = []
			if f != l[j]:
				d[l[j]].append(-1)
		d[l[j]].append(j)
	for k in d:
		m = 0
		if k != la:
			d[k].append(n)
		for j in range(len(d[k]) - 1):
			if d[k][j + 1] - d[k][j] > m:
				m = d[k][j + 1] - d[k][j]
		if ans[m] == -1:
			ans[m] = k
		else:
			ans[m] = min(ans[m], k)
	m = n
	a = False
	for j in range(1, n + 1):
		if ans[j] != -1:
			m = min(m, ans[j])
			a = True
		if a:
			ans[j] = m
	print(*ans[1:n + 1])


from sys import stdin, stdout
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, stdin.readline().split()))
	s = []
	for i in range(n):
		s.append([-1, -1])
	for i in range(n):
		s[arr[i] - 1][0] = max(s[arr[i] - 1][0], i - s[arr[i] - 1][1] - 1)
		s[arr[i] - 1][1] = i
	for i in range(n):
		s[i][0] = max(s[i][0], n - s[i][1] - 1)
	ans = [-1] * n
	for i in range(n):
		for j in range(s[i][0], n):
			if ans[j] != -1:
				break
			else:
				ans[j] = i + 1
	for i in ans:
		stdout.write(str(i) + ' ')
	print()


import sys
import itertools as it
import math as mt
import collections as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	l = I()
	f = cc.defaultdict(int)
	ff = cc.defaultdict(int)
	for i in l:
		if not f[i]:
			f[i] = -1
	for i in range(n):
		ff[l[i]] = max(ff[l[i]], i - f[l[i]])
		f[l[i]] = i
	for i in set(l):
		ff[i] = max(ff[i], n - f[i])
	ans = [-1] * n
	for i in sorted(set(l), reverse=True):
		d = ff[i]
		ans[d - 1] = i
	for i in range(n - 1):
		if ans[i] != -1:
			if ans[i + 1] == -1 or ans[i + 1] > ans[i]:
				ans[i + 1] = ans[i]
	print(*ans)


import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	a = Read.list_int()
	tmp = {}
	last = {}
	for i in range(n):
		v = i
		if a[i] in last:
			v = i - last[a[i]] - 1
		last[a[i]] = i
		if a[i] in tmp:
			if v > tmp[a[i]]:
				tmp[a[i]] = v
		else:
			tmp[a[i]] = v
	for (k, v) in last.items():
		v = n - 1 - v
		if v > tmp[k]:
			tmp[k] = v
	tmp_s = sorted(list(tmp.keys()))
	res = []
	l = 0
	for i in tmp_s:
		r = n - tmp[i]
		for j in range(l, r):
			res.append(str(i))
		if r > l:
			l = r
	for i in range(n - len(res)):
		res.append('-1')
	res.reverse()
	print(' '.join(res))
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import defaultdict
for _ in range(int(read())):
	n = int(read())
	nums = list(readi())
	count = defaultdict(int)
	maxDist = defaultdict(int)
	lastIndex = defaultdict(int)
	for num in nums:
		lastIndex[num] = -1
	for (i, num) in enumerate(nums):
		count[num] += 1
		if num in lastIndex:
			maxDist[num] = max(i - lastIndex[num], maxDist[num])
		lastIndex[num] = i
	for num in nums:
		maxDist[num] = max(n - lastIndex[num], maxDist[num])
	ansDict = defaultdict(list)
	for num in maxDist.keys():
		k = n // maxDist[num]
		if count[num] >= k:
			ansDict[maxDist[num]].append(num)
	ansList = [-1] * n
	lastMin = float('inf')
	for i in range(1, n + 1):
		if i in ansDict:
			lastMin = min(lastMin, min(ansDict[i]))
		ansList[i - 1] = lastMin if lastMin != float('inf') else -1
	print(' '.join(map(str, ansList)))


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	S = {}
	for el in arr:
		S[el] = [0]
	for i in range(len(arr)):
		S[arr[i]].append(i + 1)
	G = {}
	for key in S:
		S[key].append(n + 1)
		best = 0
		for i in range(len(S[key]) - 1):
			gap = abs(S[key][i] - S[key][i + 1])
			best = max(gap, best)
		G[key] = best
	B = {}
	for key in G:
		l = G[key]
		if l not in B:
			B[l] = key
		else:
			B[l] = min(B[l], key)
	ans = []
	for key in B:
		ans.append((key, B[key]))
	ans.sort()
	pp = []
	low = 9999999999999999
	j = 0
	for i in range(1, n + 1):
		if j < len(ans) and i == ans[j][0]:
			if ans[j][1] < low:
				low = ans[j][1]
			j += 1
		if low > 10 ** 10:
			pp.append(-1)
		else:
			pp.append(low)
	print(*pp)


import sys
input = sys.stdin.buffer.readline
T = int(input())
for _ in range(T):
	(n, ls) = (int(input()), list(map(int, input().split())))
	(last, dis) = ([0] * (n + 1), [0] * (n + 1))
	for (i, u) in enumerate(ls):
		i += 1
		dis[u] = max(dis[u], i - last[u])
		last[u] = i
	for u in range(n + 1):
		dis[u] = max(dis[u], n + 1 - last[u])
	mnk = [n + 1] * (n + 2)
	for (i, u) in enumerate(dis):
		mnk[u] = min(mnk[u], i)
	(res, pr) = ([], n + 1)
	for i in range(1, n + 1):
		pr = min(pr, mnk[i])
		res.append(-1 if pr == n + 1 else pr)
	print(*res)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = 300005
	f1 = {}
	f2 = {}
	ans = [x] * n
	for i in range(n):
		f1[a[i]] = -1
		f2[a[i]] = 0
	for i in range(n):
		f2[a[i]] = max(f2[a[i]], i - f1[a[i]])
		f1[a[i]] = i
	for i in range(n):
		f2[a[i]] = max(f2[a[i]], n - f1[a[i]])
	for i in range(n):
		ans[f2[a[i]] - 1] = min(a[i], ans[f2[a[i]] - 1])
	ans[-1] = min(a)
	for i in range(1, n):
		ans[i] = min(ans[i], ans[i - 1])
	for i in range(n):
		if ans[i] == x:
			ans[i] = -1
	print(*ans)


import sys

def main():
	n = int(sys.stdin.readline().strip())
	q = list(map(int, sys.stdin.readline().split()))
	(clovar, p, x) = ({}, [], 1000000000.0)
	for i in range(n):
		if q[i] in clovar:
			clovar[q[i]].append(i)
		else:
			clovar[q[i]] = [i]
	for o in clovar:
		t = clovar[o]
		ma = max(t[0] + 1, n - t[-1])
		dlinat = len(t) - 1
		for i in range(dlinat):
			ma = max(t[i + 1] - t[i], ma)
		p.append([ma, o])
	p.sort()
	ans = [p[0]]
	dlinap = len(p)
	for i in range(1, dlinap):
		if ans[-1][0] != p[i][0]:
			ans.append(p[i])
	ans.append([n + 1, 1000000000.0])
	dlina_1 = ans[0][0] - 1
	print(*[-1 for i in range(dlina_1)], end=' ')
	dlinaans = len(ans) - 1
	for i in range(dlinaans):
		x = min(x, ans[i][1])
		dlinax = ans[i + 1][0] - ans[i][0]
		print(*[x for o in range(dlinax)], end=' ')
	print()
for i in range(int(sys.stdin.readline().strip())):
	main()


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()

def pr(*args, end='\n'):
	for _arg in args:
		sys.stdout.write(str(_arg) + ' ')
	sys.stdout.write(end)
inf = float('inf')
from collections import defaultdict
_T_ = inin()
for _t_ in range(_T_):
	N = inin()
	A = inar()
	valToIndices = defaultdict(list)
	for (i, x) in enumerate(A):
		valToIndices[x].append(i)
	valToGap = {}
	for (x, indices) in valToIndices.items():
		maxGap = max(indices[0] + 1, N - indices[-1])
		for (i, j) in zip(indices, indices[1:]):
			maxGap = max(maxGap, j - i)
		valToGap[x] = maxGap
	best = [inf] * (N + 1)
	for (k, v) in valToGap.items():
		best[v] = min(best[v], k)
	for (k, b) in enumerate(best):
		if k >= 1:
			best[k] = min(best[k - 1], b)
	ans = [-1 if x == inf else x for x in best][1:]
	pr(' '.join(map(str, ans)))


def solve(n, a):
	maxD = [1] * (n + 1)
	lastP = [-1] * (n + 1)
	for i in range(n):
		d = i - lastP[a[i]]
		maxD[a[i]] = max(maxD[a[i]], d)
		lastP[a[i]] = i
	res = [-1] * n
	k = n
	for v in range(1, n + 1):
		if lastP[v] == -1:
			continue
		minK = max(maxD[v], n - lastP[v])
		while k >= minK:
			res[k - 1] = v
			k -= 1
	return res
tests = int(input())
for test in range(tests):
	n = int(input())
	a = list(map(int, input().split()))
	print(*solve(n, a))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	dct = {}
	for i in a:
		dct[i] = (-1, 0)
	now = 0
	for i in a:
		dct[i] = [now, max(dct[i][1], now - dct[i][0])]
		now += 1
	for i in dct:
		dct[i] = max(dct[i][1], n - dct[i][0])
	a = [(dct[i], i) for i in dct]
	a.sort()
	mini = 1000000000000000
	now = 0
	q = len(a)
	for i in range(1, n + 1):
		while now < q and a[now][0] == i:
			mini = min(mini, a[now][1])
			now += 1
		if mini == 1000000000000000:
			print(-1, end=' ')
		else:
			print(mini, end=' ')
	print()


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	(*a,) = R()
	d = {i: [-1] for i in set(a)}
	v = [-1] * n
	for i in range(n):
		d[a[i]] += (i,)
	for i in d:
		d[i] += (n,)
		df = -1
		p = d[i][0]
		for el in d[i][1:]:
			df = max(df, el - p)
			p = el
		if v[df - 1] == -1:
			v[df - 1] = i
		else:
			v[df - 1] = min(i, v[df - 1])
	flg = True
	mn = N
	for i in range(n):
		if flg:
			if v[i] > -1:
				flg = False
				mn = min(v[i], mn)
		else:
			if v[i] == -1:
				v[i] = mn
				continue
			mn = min(v[i], mn)
			v[i] = mn
	print(*v)


t = int(input())
for p in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	ind = []
	for j in range(n + 1):
		ind.append([-1])
	for j in range(n):
		ind[b[j]].append(j)
	ord = []
	j = 1
	while j <= n:
		if len(ind[j]) < 2:
			pass
		else:
			m = 0
			q = 1
			while q < len(ind[j]):
				m = max(m, ind[j][q] - ind[j][q - 1] - 1)
				q += 1
			m = max(m, n - 1 - ind[j][-1])
			ord.append([m, j])
		j += 1
	ord.sort()
	if n % 2 != 0:
		ans = []
		j = 1
		i = 0
		m = float('inf')
		while j <= n:
			while i < len(ord):
				if ord[i][0] < j:
					m = min(m, ord[i][1])
				else:
					break
				i += 1
			if m == float('inf'):
				ans.append(-1)
			else:
				ans.append(m)
			j += 1
		l = n - (n // 2 + 1)
		j = n // 2
		i = n // 2
		m = float('inf')
		while j < n and i >= 0:
			m = min(m, b[i], b[j])
			if ans[l] == -1:
				ans[l] = float('inf')
			ans[l] = min(ans[l], m)
			i += -1
			j += 1
			l += 1
	else:
		l = n // 2
		ans = []
		j = 1
		i = 0
		m = float('inf')
		while j <= n:
			while i < len(ord):
				if ord[i][0] < j:
					m = min(m, ord[i][1])
				else:
					break
				i += 1
			if m == float('inf'):
				ans.append(-1)
			else:
				ans.append(m)
			j += 1
		j = n // 2
		i = n // 2 - 1
		m = float('inf')
		while j < n and i >= 0:
			m = min(m, b[i], b[j])
			if ans[l] == -1:
				ans[l] = float('inf')
			ans[l] = min(ans[l], m)
			i += -1
			j += 1
			l += 1
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(p) for p in input().split()]
	period = [-1] * (max(arr) + 7)
	index = [-1] * (max(arr) + 7)
	for i in range(len(arr)):
		period[arr[i]] = max(period[arr[i]], i - index[arr[i]])
		index[arr[i]] = i
	for i in range(len(period)):
		period[i] = max(period[i], n - index[i])
	final = {}
	for i in range(len(period)):
		if period[i] in final:
			final[period[i]] = min(final[period[i]], i)
		else:
			final[period[i]] = i
	ans = [float('inf')] * n
	for i in range(n):
		if i + 1 in final:
			ans[i] = final[i + 1]
	curr = float('inf')
	for i in range(len(ans)):
		if ans[i] == float('inf'):
			if curr == float('inf'):
				ans[i] = -1
			else:
				ans[i] = curr
		else:
			curr = min(curr, ans[i])
			ans[i] = curr
	print(*ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	n = stdint()
	arr = list(stdarr())
	ind = dd(list)
	for i in range(n):
		ind[arr[i]].append(-1)
	for i in range(n):
		ind[arr[i]].append(i)
	for i in ind:
		ind[i].append(n)
	c = dd(list)
	for i in ind:
		l = ind[i]
		m = -1
		for j in range(len(l) - 1):
			d = l[j + 1] - l[j]
			m = max(d, m)
		c[m].append(i)
	res = [-1] * n
	for i in range(n):
		if len(c[i + 1]) == 0:
			if i != 0:
				res[i] = res[i - 1]
		elif res[i - 1] == -1:
			res[i] = min(c[i + 1])
		else:
			res[i] = min(res[i - 1], min(c[i + 1]))
	print(*res)


fullans = ''
for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	ar = [[] for i in range(n)]
	ans = [None] * n
	for i in range(n):
		ar[ls[i] - 1].append(i)
	for j in range(n):
		if len(ar[j]) == 0:
			continue
		mn = ar[j][0]
		for i in range(1, len(ar[j])):
			mn = max(ar[j][i] - ar[j][i - 1] - 1, mn)
		mn = max(n - 1 - ar[j][-1], mn)
		if ans[mn] is None:
			ans[mn] = j + 1
	curr = -1
	for i in range(n):
		if ans[i] is None:
			ans[i] = curr
		elif curr == -1:
			curr = ans[i]
		else:
			curr = min(ans[i], curr)
			ans[i] = curr
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		temp = dic.get(a[i], 0)
		if temp == 0:
			dic[a[i]] = [i + 1, 0, n - i]
		else:
			dic[a[i]] = [temp[0], max(temp[1], temp[2] - (n - i)), n - i]
	lis = []
	ans = [300001] * n
	for (k, v) in dic.items():
		MAX = max(v)
		ans[MAX - 1] = min(k, ans[MAX - 1])
	if ans[0] == 300001:
		ans[0] = -1
	for i in range(1, n):
		if ans[i - 1] == -1:
			if ans[i] == 300001:
				ans[i] = -1
		else:
			ans[i] = min(ans[i - 1], ans[i])
	print(' '.join((str(n) for n in ans)))


import sys
import math
input = sys.stdin.readline

def algo(arr, n):
	ans = [-1] * (n + 1)
	f = [0] * (n + 1)
	idx = [0] * (n + 1)
	for i in range(1, n + 1):
		f[arr[i - 1]] = max(i - idx[arr[i - 1]], f[arr[i - 1]])
		idx[arr[i - 1]] = i
	for i in range(1, n + 1):
		f[arr[i - 1]] = max(n + 1 - idx[arr[i - 1]], f[arr[i - 1]])
	for i in range(1, n + 1):
		if ans[f[i]] == -1:
			ans[f[i]] = i
	ans[0] = -1
	for i in range(1, n + 1):
		if ans[i] == -1:
			ans[i] = ans[i - 1]
		else:
			ans[i] = ans[i] if ans[i - 1] == -1 else min(ans[i], ans[i - 1])
	return ' '.join(map(str, ans[1:]))
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	res = algo(arr, n)
	print(res)


import sys
input = sys.stdin.buffer.readline

def prog():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		locs = [[-1] for u in range(n + 1)]
		for i in range(n):
			locs[a[i]].append(i)
		for i in range(1, n + 1):
			locs[i].append(n)
		b = []
		for i in range(1, n + 1):
			if len(locs[i]) > 1:
				gap = 0
				for j in range(1, len(locs[i])):
					gap = max(gap, locs[i][j] - locs[i][j - 1])
				b.append([gap, i])
		b.sort()
		idx = 0
		mn = 10 ** 9
		output = [0] * n
		for k in range(1, n + 1):
			while idx < len(b) and k >= b[idx][0]:
				mn = min(mn, b[idx][1])
				idx += 1
			if idx == 0:
				output[k - 1] = -1
			else:
				output[k - 1] = mn
		print(*output)
prog()


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	setA = set(A)
	if len(setA) == 1:
		print(*[A[0]] * n)
		continue
	last_pos = [-1] * (n + 1)
	max_dis = [0] * (n + 1)
	for (i, a) in enumerate(A):
		max_dis[a] = max(max_dis[a], i - last_pos[a])
		last_pos[a] = i
	for a in list(setA):
		max_dis[a] = max(max_dis[a], n - last_pos[a])
	res = [-1] * n
	for (i, dis) in enumerate(max_dis):
		if dis == 0:
			continue
		elif res[dis - 1] == -1:
			res[dis - 1] = i
	for i in range(n - 1):
		if res[i] != -1:
			if res[i + 1] > res[i] or res[i + 1] == -1:
				res[i + 1] = res[i]
	print(*res)


def ind(lst, m):
	result = []
	for ab in range(m):
		result.append([-1])
	for z in range(m):
		result[lst[z] - 1].append(z)
	for ab in range(m):
		result[ab].append(m)
	return result
t = int(input())
for i in range(t):
	n = int(input())
	ans = [-1] * n
	a = [int(x) for x in input().split()]
	s = set(a)
	te = ind(a, n)
	for j in s:
		maxx = -1
		for k in range(len(te[j - 1]) - 1):
			maxx = max(maxx, te[j - 1][k + 1] - te[j - 1][k])
		for k in range(maxx - 1, n):
			if ans[k] != -1:
				if ans[k] > j:
					ans[k] = j
				else:
					break
			else:
				ans[k] = j
	print(*ans)


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

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

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		ar = inpt()
		ans = [-1] * n
		d = defaultdict(set)
		temp = defaultdict(list)
		for i in range(n):
			d[ar[i]].add(i)
			temp[ar[i]].append(i)
		tp = list(set(ar))
		tp.sort()
		gl = 10 ** 9
		for i in tp:
			temp[i].insert(0, -1)
			temp[i].append(n)
			mn = 0
			for j in range(len(temp[i]) - 1):
				mn = max(mn, abs(temp[i][j] - temp[i][j + 1]))
			if gl > mn:
				gl = mn
				ans[mn - 1] = i
		v = -1
		for i in range(n):
			if ans[i] != -1:
				v = ans[i]
			ans[i] = v
		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()


for qq in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	last = [-1] * (n + 1)
	dura = [-1] * (n + 1)
	for i in range(n):
		dura[a[i]] = max(dura[a[i]], i - last[a[i]] - 1)
		last[a[i]] = i
	for i in range(n + 1):
		dura[i] = max(dura[i], n - last[i] - 1)
	ans = [n + 1] * n
	for i in range(n + 1):
		if dura[i] == n:
			continue
		ans[dura[i]] = min(ans[dura[i]], i)
	for i in range(n - 1):
		ans[i + 1] = min(ans[i + 1], ans[i])
	for i in range(n):
		if ans[i] == n + 1:
			ans[i] = -1
	print(*ans)


for _ in range(int(input())):
	(n, values) = (int(input()), [0] + [int(i) for i in input().split()])
	(last, dist, ans) = ([0 for i in range(n + 1)], [0 for i in range(n + 1)], [-1 for i in range(n + 1)])
	for i in range(1, n + 1):
		dist[values[i]] = max(dist[values[i]], i - last[values[i]])
		last[values[i]] = i
	for i in range(1, n + 1):
		dist[i] = max(dist[i], n - last[i] + 1)
		for j in range(dist[i], n + 1):
			if ans[j] != -1:
				break
			ans[j] = i
	print(*ans[1:])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = [-1] * (n + 1)
	b = [[] for i in range(n + 1)]
	for i in range(n):
		b[a[i]].append(i + 1)
	p = n
	for i in range(1, n + 1):
		if b[i] == []:
			continue
		m = 0
		m = b[i][0]
		for j in range(1, len(b[i])):
			m = max(b[i][j] - b[i][j - 1], m)
		m = max(m, n + 1 - b[i][-1])
		if m > p:
			continue
		for k in range(m, p + 1):
			res[k] = i
		p = m - 1
	print(*res[1:])


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	_A = sorted(set(a))
	ind = defaultdict(lambda : [0])
	for i in range(n):
		ind[a[i]].append(i + 1)
	for i in ind:
		ind[i].append(n + 1)
	ans = [inf] * (n + 1)
	for i in _A:
		ma = 1
		for j in range(1, len(ind[i])):
			ma = max(ind[i][j] - ind[i][j - 1], ma)
		ans[ma] = min(i, ans[ma])
	ans = ans[1:]
	last = inf
	for i in range(len(ans)):
		ans[i] = min(last, ans[i])
		last = ans[i]
		if last == inf:
			ans[i] = -1
	print(*ans)


def func(n, a):
	c = [-1] * (n + 1)
	f = [0] * (n + 1)
	indices = [[] for _ in range(n + 1)]
	for i in range(n):
		indices[a[i]].append(i + 1)
	for i in range(1, n + 1):
		lis = indices[i]
		if lis != []:
			m = max(lis[0], n - lis[-1] + 1)
			for j in range(1, len(lis)):
				m = max(m, lis[j] - lis[j - 1])
			f[i] = m
	for i in range(1, n + 1):
		m = f[i]
		if m != 0:
			while m < n + 1 and c[m] == -1:
				c[m] = i
				m += 1
	return c[1:]
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = func(n, arr)
	print(' '.join(list(map(str, brr))))


t = int(input())
for w in range(t):
	n = int(input())
	a = tuple(map(int, input().split()))
	d = {}
	for (i, x) in enumerate(a):
		if x not in d:
			d[x] = [i + 1, i + 1]
		else:
			d[x] = [i + 1, max(d[x][1], i + 1 - d[x][0])]
	l = len(a) + 1
	for i in d:
		d[i] = max(d[i][1], l - d[i][0])
	z = {}
	for (i, x) in list(d.items()):
		if x in z:
			if z[x] > i:
				z[x] = i
		else:
			z[x] = i
	q = [-1 for x in range(n)]
	for (i, x) in list(z.items()):
		q[i - 1] = x
	q1 = []
	m = -1
	for x in q:
		if x == -1:
			q1.append(m)
		else:
			if m != -1:
				m = min(m, x)
			else:
				m = x
			q1.append(m)
	print(' '.join((str(x) for x in q1)))


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 *
from collections import deque
from operator import itemgetter, attrgetter
from decimal import *
import bisect
import math
import heapq as hq
MOD = 10 ** 9 + 7

def is_prime(n):
	if n == 2 or n == 3:
		return True
	if n < 2 or n % 2 == 0:
		return False
	if n < 9:
		return True
	if n % 3 == 0:
		return False
	r = int(n ** 0.5)
	f = 5
	while f <= r:
		if n % f == 0:
			return False
		if n % (f + 2) == 0:
			return False
		f += 6
	return True

def pow(a, b, m):
	ans = 1
	while b:
		if b & 1:
			ans = ans * a % m
		b //= 2
		a = a * a % m
	return ans
vis = []
graph = []

def dfs(v):
	if vis[v]:
		return 0
	vis[v] = True
	temp = 0
	for vv in graph[v]:
		temp += dfs(vv)
	return 1 + temp

def ispalindrome(s):
	if s[:] == s[::-1]:
		return 1
	return 0
for _ in range(int(input())):
	n = int(input())
	t = list(map(int, input().split()))
	l = [0]
	ans = [-1 for i in range(n + 1)]
	for i in t:
		l.append(i)
	maxdiff = [0 for i in range(n + 1)]
	last = [0 for i in range(n + 1)]
	for i in range(1, n + 1):
		maxdiff[l[i]] = max(maxdiff[l[i]], i - last[l[i]])
		last[l[i]] = i
	for x in range(1, n + 1):
		maxdiff[x] = max(maxdiff[x], n + 1 - last[x])
		for i in range(maxdiff[x], n + 1):
			if ans[i] != -1:
				break
			ans[i] = x
	for i in range(1, n + 1):
		print(ans[i], end=' ')
	print()


from sys import stdin
t = int(stdin.readline())
for case in range(t):
	n = int(stdin.readline())
	array = list(map(int, stdin.readline().split()))
	dict1 = {}
	dict2 = {}
	ans = [-1] * n
	for i in range(n):
		if array[i] not in dict2:
			dict2[array[i]] = i
			dict1[array[i]] = i
		else:
			dict2[array[i]] = max(dict2[array[i]], i - dict1[array[i]] - 1)
			dict1[array[i]] = i
	for i in dict2:
		dict2[i] = max(dict2[i], n - dict1[i] - 1)
	sorts = sorted(list(dict2.keys()))
	for i in sorts:
		for j in range(dict2[i], n):
			if ans[j] != -1:
				break
			else:
				ans[j] = i
	print(' '.join([str(i) for i in ans]))


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

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

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')

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

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

def itg():
	return int(sys.stdin.readline())
INF = int(1000000.0)

def solve():
	n = itg()
	arr = tuple(mpint())
	index_dict = {}
	max_dis = {}
	for a in arr:
		index_dict[a] = -1
		max_dis[a] = -INF
	for (i, a) in enumerate(arr):
		max_dis[a] = max(max_dis[a], i - index_dict[a])
		index_dict[a] = i
	for key in max_dis:
		max_dis[key] = max(max_dis[key], n - index_dict[key])
	ans = [-1] * n
	for key in sorted(max_dis, reverse=True):
		dis = max_dis[key]
		ans[dis - 1] = key
	for i in range(n - 1):
		if ans[i] == -1:
			continue
		if ans[i + 1] == -1 or ans[i + 1] > ans[i]:
			ans[i + 1] = ans[i]
	return ans
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
for _ in range(itg()):
	print(*solve())


gans = []
for _ in range(int(input())):
	n = int(input())
	u = list(map(int, input().split()))
	d = dict()
	w = []
	v = []
	ind = 0
	for i in range(n):
		if u[i] not in d.keys():
			d[u[i]] = ind
			w.append([])
			w[ind].append(i)
			ind += 1
			v.append(u[i])
		else:
			w[d[u[i]]].append(i)
	m = ind
	vans = [0] * m
	for i in range(m):
		mx = max(w[i][0] + 1, n - w[i][-1])
		for j in range(1, len(w[i])):
			mx = max(w[i][j] - w[i][j - 1], mx)
		vans[i] = (mx, -v[i])
	vans.sort()
	ans = [0] * n
	vv = [-1] * n
	ind = 0
	for i in range(n):
		if vans[ind][0] > i + 1:
			continue
		while ind + 1 < len(vans) and vans[ind + 1][0] <= i + 1:
			ind += 1
		vv[i] = -vans[ind][1]
		if i > 0 and vv[i - 1] != -1:
			vv[i] = min(vv[i], vv[i - 1])
	gans.append(' '.join(map(str, vv)))
print('\n'.join(gans))


import math

def get_int():
	return int(input())

def get_ints():
	return [int(i) for i in input().split()]
for t in range(0, get_int()):
	n = get_int()
	nums = get_ints()
	hist = {}
	for i in range(0, n):
		e = nums[i]
		if e in hist:
			hist[e].append(i)
		else:
			hist[e] = [i]
	results = [-1] * n
	filled = n + 1
	for e in sorted(hist):
		gap = -1
		last_idx = -1
		for x in hist[e]:
			gap = max(gap, x - last_idx)
			last_idx = x
		gap = max(gap, n - hist[e][-1])
		tmp = gap
		while gap < filled:
			results[gap - 1] = e
			gap += 1
		filled = min(tmp, filled)
	print(*results, sep=' ')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [10 ** 6] * n
	mn = dict()
	for i in range(n):
		if a[i] in mn:
			mn[a[i]].append(i)
		else:
			mn[a[i]] = [i, -1, n]
	for i in mn:
		c = 0
		mn[i].sort()
		for j in range(1, len(mn[i])):
			c = max(c, mn[i][j] - mn[i][j - 1] - 1)
		b[c] = min(b[c], i)
	b[-1] = min(a)
	for i in range(1, n):
		b[i] = min(b[i], b[i - 1])
	for i in range(n):
		if b[i] == 10 ** 6:
			b[i] = -1
	print(*b)


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def input_int():
	return int(input())

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

def print_int_list(l):
	cout << ' '.join(map(str, l)) << endl

def solve():
	t = int(input())
	for _ in range(t):
		n = input_int()
		arr = input_int_list()
		mx_k_vals = [0] * (n + 1)
		prev = [0] * (n + 1)
		res = [-1] * (n + 1)
		for i in range(1, n + 1):
			ele = arr[i - 1]
			mx_k_vals[ele] = max(mx_k_vals[ele], i - prev[ele])
			prev[ele] = i
		for i in range(1, n + 1):
			mx_k_vals[i] = max(mx_k_vals[i], n - prev[i] + 1)
			for k_val in range(mx_k_vals[i], n + 1):
				if res[k_val] != -1:
					break
				res[k_val] = i
		print_int_list(res[1:])

def main():
	solve()
main()


import array

def readis():
	return map(int, input().strip().split())
T = int(input())

def best_k(idxs_sorted, n):
	best = -1
	last = -1
	for idx in idxs_sorted:
		best = max(best, idx - last)
		last = idx
	return max(best, n - last)
while T:
	T -= 1
	n = int(input())
	d = {x: [] for x in range(n + 1)}
	for (idx, x) in enumerate(readis()):
		d[x].append(idx)
	d = {x: best_k(idxs, n) for (x, idxs) in d.items() if idxs}
	ans = array.array('i', (-1 for _ in range(n)))
	for (x, best) in d.items():
		idx = best - 1
		while idx < n and ans[idx] == -1:
			ans[idx] = x
			idx += 1
	print(' '.join(map(str, ans)))


from sys import stdin, stdout, setrecursionlimit
import threading

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			n = int(R())
			a = [0] + [int(x) for x in R().split()]
			tmp_max_gap = {}
			for j in range(1, n + 1):
				if a[j] not in tmp_max_gap:
					tmp_max_gap[a[j]] = [j, j]
				else:
					tmp_max_gap[a[j]][0] = max(tmp_max_gap[a[j]][0], j - tmp_max_gap[a[j]][1])
					tmp_max_gap[a[j]][1] = j
			max_gap = []
			for j in tmp_max_gap:
				max_gap.append((j, max(tmp_max_gap[j][0], n + 1 - tmp_max_gap[j][1])))
			max_gap.sort(key=lambda x: x[0])
			color = ['-1' for j in range(n + 1)]
			pos = n + 1
			for j in range(len(max_gap)):
				if max_gap[j][1] < pos:
					color[max_gap[j][1]] = str(max_gap[j][0])
					pos = max_gap[j][1]
			val = '-1'
			for j in range(1, n + 1):
				if color[j] != val and color[j] != '-1':
					val = color[j]
				color[j] = str(val)
			ans.append(' '.join(color[1:]))
		W('\n'.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()
pr = print
inf = float('inf')
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	last = [-1 for i in range(n + 1)]
	gap = [-1 for i in range(n + 1)]
	for (inde, i) in enumerate(a):
		gap[i] = max(gap[i], inde - last[i])
		last[i] = inde
	for i in a:
		gap[i] = max(gap[i], n - last[i])
	gapmin = [inf for i in range(n + 1)]
	for i in range(1, n + 1):
		if gap[i] == -1:
			continue
		gapmin[gap[i]] = min(gapmin[gap[i]], i)
	ans = [inf for i in range(n + 1)]
	for i in range(1, n + 1):
		ans[i] = min(ans[i - 1], gapmin[i])
	for i in range(n + 1):
		if ans[i] == inf:
			ans[i] = -1
	pr(*ans[1:])


import os
import sys
import io
import functools
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
GANS = []

def cmp(x, y):
	if x[1] == y[1]:
		return y[0] - x[0]
	return x[1] - y[1]
t = int(input())
for _ in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	ctr = {}
	for i in li:
		ctr[i] = ctr.get(i, 0) + 1
	c2 = {}
	prv = {}
	d = {}
	for (p, i) in enumerate(li):
		c2[i] = c2.get(i, 0) + 1
		if i not in d:
			d[i] = p
		else:
			d[i] = max(p - prv.get(i, 0), d[i])
		if c2[i] == ctr[i]:
			d[i] = max(n - p - 1, d[i])
		prv[i] = p + 1
	srt = sorted(d.items(), key=functools.cmp_to_key(cmp))
	p = -1
	cur = 11451141919810
	for k in range(n):
		while p < len(srt) - 1 and srt[p + 1][1] <= k:
			p += 1
			cur = min(srt[p][0], cur)
		if cur == 11451141919810:
			print(-1, end=' ')
		else:
			print(cur, end=' ')
	print()


import sys
import math

def II():
	return int(sys.stdin.readline())

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

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

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	d = [[] for i in range(n + 1)]
	d2 = [0] * (n + 1)
	dp = [0] * (n + 1)
	for i in range(n):
		if d2[a[i]] == 0:
			d2[a[i]] = 1
			d[a[i]].append(i)
			dp[a[i]] = i + 1
		else:
			d2[a[i]] += 1
			dp[a[i]] = max(dp[a[i]], i - d[a[i]][-1])
			d[a[i]].append(i)
	for i in range(n):
		dp[a[i]] = max(dp[a[i]], n - d[a[i]][-1])
	ans = [-1] * (n + 1)
	temp = -1
	for i in range(n + 1):
		if ans[dp[i]] == -1:
			ans[dp[i]] = i
	temp = -1
	for i in range(1, n + 1):
		if ans[i] != -1:
			if temp == -1:
				temp = ans[i]
			elif ans[i] < temp:
				temp = ans[i]
			else:
				ans[i] = temp
		else:
			ans[i] = temp
	print(*ans[1:])


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

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	index = defaultdict(lambda : [-1])
	for (i, v) in enumerate(a):
		index[v].append(i)
	res = [-1] * n
	pre = n
	for i in sorted(index.keys()):
		gap = -1
		index[i].append(n)
		for (a, b) in zip(index[i], index[i][1:]):
			gap = max(gap, b - a)
		if gap - 1 < pre:
			for j in range(gap - 1, pre):
				res[j] = i
			pre = gap - 1
	print(' '.join(map(str, res)))
t = int(input())
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline
tests = int(input())
for case in range(tests):
	n = int(input())
	ans = [1000000001] * n
	a = list(map(int, input().split()))
	k = dict()
	for i in range(n):
		if a[i] not in k:
			k[a[i]] = [i]
		else:
			k[a[i]].append(i)
	z = dict()
	for key in k:
		d = 0
		if k[key][0] != 0:
			d = max(d, k[key][0] + 1)
		for i in range(1, len(k[key])):
			d = max(d, abs(k[key][i] - k[key][i - 1]))
		if k[key][-1] != n - 1:
			d = max(d, n - k[key][-1])
		if d in z:
			z[d] = min(z[d], key)
		else:
			z[d] = key
	for i in range(len(ans)):
		if i > 0:
			if i + 1 in z:
				ans[i] = min(z[i + 1], ans[i - 1] if ans[i - 1] != -1 and ans[i - 1] != 1000000001 else z[i + 1])
			elif ans[i - 1] == -1 or ans[i - 1] == 1000000001:
				(ans[i], ans[i - 1]) = (-1, -1)
			else:
				ans[i] = ans[i - 1]
		elif i + 1 in z:
			ans[i] = z[i + 1]
		else:
			ans[i] = -1
	print(*ans)


for anynumber in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for (index, i) in enumerate(l):
		if i not in d.keys():
			d[i] = [index + 1, index]
		else:
			d[i] = [max(index - d[i][1], d[i][0]), index]
	for i in d.keys():
		d[i] = max(d[i][0], n - d[i][1])
	ans = [-1 for i in range(n)]
	for i in sorted(d.keys(), reverse=True):
		ans[d[i] - 1] = i
	for i in range(1, n):
		if ans[i] == -1:
			ans[i] = ans[i - 1]
		elif ans[i - 1] != -1:
			if ans[i - 1] < ans[i]:
				ans[i] = ans[i - 1]
	for i in range(n - 1):
		print(ans[i], end=' ')
	print(ans[n - 1])


t = int(input())
ns = []
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	nums = set(arr)
	dct1 = {}
	dct2 = {num: 0 for num in nums}
	for (idx, el) in enumerate(arr):
		if el in dct1:
			dct2[el] = max(dct2[el], idx - dct1[el])
		else:
			dct2[el] = idx + 1
		dct1[el] = idx
	for el in dct2:
		dct2[el] = max(dct2[el], n - dct1[el])
	ans = []
	temp = sorted(nums, key=lambda x: dct2[x])
	index = 0
	mini = 10 ** 20
	for k in range(1, n + 1):
		while index < len(temp) and dct2[temp[index]] == k:
			mini = min(mini, temp[index])
			index += 1
		if mini == 10 ** 20:
			ans.append(-1)
		else:
			ans.append(mini)
	ns.append(ans)
for el in ns:
	print(' '.join(list(map(str, el))))


from sys import stdin
input = stdin.readline

def kamzing(arr, n):
	arr = [0] + arr
	(last, f, ans) = ([0] * len(arr), [0] * len(arr), [-1] * len(arr))
	for i in range(1, n + 1):
		x = arr[i]
		f[x] = max(f[x], i - last[x])
		last[x] = i
	for x in range(1, n + 1):
		f[x] = max(f[x], n - last[x] + 1)
		for i in range(f[x], n + 1):
			if ans[i] != -1:
				break
			ans[i] = x
	print(*ans[1:])
	return ''
for i in range(int(input())):
	a = int(input())
	lst = list(map(int, input().strip().split()))
	print(kamzing(lst, a))


from __future__ import division, print_function
import os
import sys
from collections import defaultdict
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	INF = float('inf')
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = [int(ai) for ai in input().split()]
		last = defaultdict(lambda : -1)
		poss = defaultdict(int)
		for (i, j) in enumerate(a):
			poss[j] = max(poss[j], i - last[j])
			last[j] = i
		for key in last:
			poss[key] = max(poss[key], n - last[key])
		sol = [INF] * n
		for (key, value) in poss.items():
			sol[value - 1] = min(sol[value - 1], key)
		for i in range(1, n):
			sol[i] = min(sol[i - 1], sol[i])
		print(*[-1 if i == INF else i for i in sol])
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys

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

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

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

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k 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 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
for _ in range(INT()):
	N = INT()
	A = LIST()
	adjli = [[-1] for i in range(N + 1)]
	for (i, a) in enumerate(A):
		adjli[a].append(i)
	for i in range(1, N + 1):
		adjli[i].append(N)
	ans = [INF] * (N + 1)
	for i in range(1, N + 1):
		mx = 0
		if len(adjli[i]) >= 3:
			for j in range(len(adjli[i]) - 1):
				mx = max(mx, adjli[i][j + 1] - adjli[i][j])
			if mx != 0:
				ans[mx] = min(ans[mx], i)
	for i in range(1, N + 1):
		ans[i] = min(ans[i], ans[i - 1])
	ans = [a if a != INF else -1 for a in ans]
	print(*ans[1:])


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	dic = dd(list)
	ch = sorted(list(set(arr)))
	for i in ch:
		dic[i].append(-1)
	for i in range(n):
		dic[arr[i]].append(i)
	for i in ch:
		dic[i].append(n)
	ans = [None] * (n + 1)
	ans[n] = min(arr)
	dic2 = dd(lambda : float('inf'))
	for i in ch:
		diff = -float('inf')
		for j in range(len(dic[i]) - 1):
			diff = max(diff, dic[i][j + 1] - dic[i][j])
		if diff == -float('inf'):
			pass
		else:
			dic2[diff] = min(dic2[diff], i)
	cur = float('inf')
	for i in range(1, n):
		cur = min(cur, dic2[i])
		if cur == float('inf'):
			ans[i] = -1
		else:
			ans[i] = cur
	ans.pop(0)
	print(*ans)


t = int(input())
for tc in range(t):
	n = int(input())
	arr = [int(z) for z in input().split()]
	occ = {}
	for i in range(n):
		if not occ.get(arr[i]):
			occ[arr[i]] = []
		occ[arr[i]].append(i + 1)
	ref = sorted(occ.keys())
	res = [-1] * (n + 1)
	for i in ref:
		(mx, prev) = (0, 0)
		for u in occ[i]:
			mx = max(mx, u - prev)
			prev = u
		mx = max(mx, n + 1 - prev)
		for pl in range(mx, n + 1):
			if res[pl] > -1:
				break
			res[pl] = i
	del res[0]
	print(*res)


import sys, os, io
input = sys.stdin.readline
T = int(input())
from collections import defaultdict
for t in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	max_dif = defaultdict(lambda : 0)
	bef = defaultdict(lambda : -1)
	for i in range(n):
		max_dif[A[i]] = max(max_dif[A[i]], i - bef[A[i]])
		bef[A[i]] = i
	for k in max_dif.keys():
		max_dif[k] = max(max_dif[k], n - bef[k])
	lis = sorted(max_dif.items(), key=lambda x: (x[1], x[0]))
	lis2 = lis[1:] + [(n + 1, n + 1)]
	ans = [0] * n
	for j in range(lis[0][1] - 1):
		ans[j] = -1
	cum = n
	for ((k, v), (k1, v1)) in zip(lis, lis2):
		cum = min(cum, k)
		for j in range(v - 1, v1 - 1):
			ans[j] = cum
	print(*ans)


import math
import collections
t = int(input())
for w in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l1 = [0] * n
	d = {}
	for i in range(n):
		if l[i] not in d:
			if i == 0:
				d[l[i]] = [i]
			else:
				d[l[i]] = [-1, i]
		else:
			d[l[i]].append(i)
	for i in d:
		if d[i][-1] != n - 1:
			d[i].append(n)
	m = n
	d = collections.OrderedDict(sorted(d.items()))
	for i in d:
		d1 = 0
		for j in range(len(d[i]) - 1):
			d1 = max(d1, d[i][j + 1] - d[i][j])
		for j in range(d1 - 1, m):
			l1[j] = i
		m = min(m, d1 - 1)
	for i in range(m):
		l1[i] = -1
	print(*l1)


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')

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

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // lcm(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		n = N()
		arr = RLL()
		rec = defaultdict(int)
		pre = defaultdict(int)
		for i in range(n):
			now = arr[i]
			if now in pre:
				rec[now] = max(rec[now], i - pre[now])
			else:
				rec[now] = max(rec[now], i + 1)
			pre[now] = i
		for i in pre:
			rec[i] = max(rec[i], n - pre[i])
		res = [-1] * n
		for i in rec:
			gp = rec[i]
			if gp - 1 < n:
				if res[gp - 1] == -1:
					res[gp - 1] = i
				else:
					res[gp - 1] = min(res[gp - 1], i)
		mi = 10 ** 9
		for i in range(n):
			if res[i] != -1:
				mi = min(res[i], mi)
			if mi != 10 ** 9:
				if res[i] != -1:
					res[i] = min(res[i], mi)
				else:
					res[i] = mi
		print(*res)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	last_same = {}
	for a in arr:
		last_same[a] = (-1, 1)
	for (i, a) in enumerate(arr):
		last_same[a] = (i, max(last_same[a][1], i - last_same[a][0]))
	for a in last_same.keys():
		last_same[a] = (last_same[a][0], max(last_same[a][1], len(arr) - last_same[a][0]))
	ans = [-1] * len(arr)
	for a in sorted(list(last_same.keys())):
		pos = last_same[a][1] - 1
		while pos < len(ans) and ans[pos] == -1:
			ans[pos] = a
			pos += 1
	print(' '.join(map(str, ans)))


from collections import defaultdict
t = int(input())
for _ in range(t):
	max_dist = defaultdict(lambda : -1)
	last_index = defaultdict(lambda : -1)
	n = int(input())
	nums = list(map(int, input().split()))
	for (i, num) in enumerate(nums):
		max_dist[num] = max(max_dist[num], i - last_index[num])
		last_index[num] = i
	for key in max_dist.keys():
		max_dist[key] = max(max_dist[key], n - last_index[key])
	answer = [float('inf')] * n
	for key in max_dist.keys():
		value = max_dist[key]
		answer[value - 1] = min(answer[value - 1], key)
	for i in range(1, n):
		answer[i] = min(answer[i], answer[i - 1])
	for a in answer:
		if a == float('inf'):
			print(-1, end=' ')
		else:
			print(a, end=' ')
	print()


from functools import cmp_to_key
from collections import deque
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
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')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

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

def ii():
	return int(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def sli():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

class UnionFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)

def custom_sort(lista):

	def cmp(x, y):
		if x + y > y + x:
			return 1
		else:
			return -1
	return sorted(lista, key=cmp_to_key(cmp))
MOD = 10 ** 9 + 7
maxN = 10 ** 5
FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def coeffBinom(n, k):
	if n < k:
		return 0
	return divide(FACT[n], multiply(FACT[k], FACT[n - k]))

def primes(N):
	smallest_prime = [1] * (N + 1)
	prime = []
	smallest_prime[0] = 0
	smallest_prime[1] = 0
	for i in range(2, N + 1):
		if smallest_prime[i] == 1:
			prime.append(i)
			smallest_prime[i] = i
		j = 0
		while j < len(prime) and i * prime[j] <= N:
			smallest_prime[i * prime[j]] = min(prime[j], smallest_prime[i])
			j += 1
	return (prime, smallest_prime)

def gcd(a, b):
	(s, t, r) = (0, 1, b)
	(old_s, old_t, old_r) = (1, 0, a)
	while r != 0:
		quotient = old_r // r
		(old_r, r) = (r, old_r - quotient * r)
		(old_s, s) = (s, old_s - quotient * s)
		(old_t, t) = (t, old_t - quotient * t)
	return (old_r, old_s, old_t)

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def create_edges(m, unweighted=0):
	edges = list()
	if unweighted:
		for i in range(m):
			edges.append(li(lag=-1))
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			edges.append([w, x, y])
	return edges

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def connected(graph, n):
	v = dfs(graph, n, 0)
	for el in v:
		if el == -1:
			return False
	return True

def topological(graph, n):
	indegree = [0] * n
	for el in range(n):
		for child in graph[el]:
			indegree[child] += 1
	s = deque()
	for el in range(n):
		if indegree[el] == 0:
			s.append(el)
	order = []
	while s:
		el = s.popleft()
		order.append(el)
		for child in graph[el]:
			indegree[child] -= 1
			if indegree[child] == 0:
				s.append(child)
	if n == len(order):
		return (False, order)
	else:
		return (True, [])

def bipartite(graph, n):
	color = [-1] * n
	color[0] = 0
	s = [0]
	while s:
		el = s.pop()
		for child in graph[el]:
			if color[child] == color[el]:
				return False
			if color[child] == -1:
				s.append(child)
			color[child] = 1 - color[el]
	return True

def dijkstra(graph, n, A):
	dist = [float('inf') for i in range(n)]
	prev = [-1 for i in range(n)]
	dist[A] = 0
	pq = []
	heappush(pq, [0, A])
	while pq:
		[d_v, v] = heappop(pq)
		if d_v != dist[v]:
			continue
		for (to, w) in graph[v]:
			if dist[v] + w < dist[to]:
				dist[to] = dist[v] + w
				prev[to] = v
				heappush(pq, [dist[to], to])
	return (dist, prev)

def dijkstra_0_1(graph, n, A):
	dist = [float('inf') for i in range(n)]
	dist[A] = 0
	p = deque()
	p.append(A)
	while p:
		v = p.popleft()
		for (to, w) in graph[v]:
			if dist[v] + w < dist[to]:
				dist[to] = dist[v] + w
			if w == 1:
				q.append(to)
			else:
				q.appendleft(to)
	return dist

def floyd_warshall(graph, n):
	dist = [[float('inf') for _ in range(n)] for _ in range(n)]
	for i in range(n):
		dist[i][i] = 0
		for (child, d) in graph[i]:
			dist[i][child] = d
			dist[child][i] = d
	for k in range(n):
		for i in range(n):
			for j in range(j):
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
	return dist

def minimum_spanning_tree(edges, n):
	edges = sorted(edges)
	union_find = UnionFind(n)
	used_edges = list()
	for (w, x, y) in edges:
		if union_find.find(x) != union_find.find(y):
			union_find.merge(x, y)
			used_edges.append([w, x, y])
	return used_edges

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path

def finding_ancestors(parent, queries, n):
	steps = int(ceil(log(n, 2)))
	ancestors = [[-1 for i in range(n)] for j in range(steps)]
	ancestors[0] = parent
	for i in range(1, steps):
		for node in range(n):
			if ancestors[i - 1][node] != -1:
				ancestors[i][node] = ancestors[i - 1][ancestors[i - 1][node]]
	result = []
	for (node, k) in queries:
		ans = node
		if k >= n:
			ans = -1
		i = 0
		while k > 0 and ans != -1:
			if k % 2:
				ans = ancestors[i][ans]
			k = k // 2
			i += 1
		result.append(ans)
	return result

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def nearest_from_the_left_smaller_elements(arr):
	n = len(arr)
	res = [-1] * n
	s = []
	for (i, el) in enumerate(arr):
		while s and s[-1] >= el:
			s.pop()
		if s:
			res[i] = s[-1]
		s.append(el)
	return res

def sliding_window_minimum(arr, k):
	res = []
	q = deque()
	for (i, el) in enumerate(arr):
		while q and arr[q[-1]] >= el:
			q.pop()
		q.append(i)
		while q and q[0] <= i - k:
			q.popleft()
		if i >= k - 1:
			res.append(arr[q[0]])
	return res
t = ii()
for test in range(t):
	n = ii()
	a = li()
	occ = [[-1] for i in range(n + 1)]
	for i in range(n):
		occ[a[i]].append(i)
	for i in range(n + 1):
		occ[i].append(n)
	min_k = [-1 for i in range(n + 1)]
	curr_k = n
	for i in range(1, n + 1):
		max_diff = 0
		for j in range(1, len(occ[i])):
			max_diff = max(max_diff, occ[i][j] - occ[i][j - 1])
		if max_diff > n:
			min_k[i] = -1
		else:
			min_k[i] = max_diff
	res = [-1 for i in range(n)]
	curr_k = n + 1
	for i in range(1, n + 1):
		if min_k[i] != -1 and min_k[i] < curr_k:
			for j in range(min_k[i] - 1, curr_k - 1):
				res[j] = i
			curr_k = min_k[i]
	print_list(res)


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	pre = {}
	gap = {}
	for (i, ai) in enumerate(a):
		if ai in pre:
			gap[ai] = max(gap[ai], i - pre[ai] - 1)
		else:
			gap[ai] = i
		pre[ai] = i
	for ai in pre:
		gap[ai] = max(gap[ai], n - pre[ai] - 1)
	ans = [(gap[ai], ai) for ai in gap]
	ans.sort()
	p = 0
	cur = int(1000000000.0)
	for i in range(n):
		while p < len(ans) and ans[p][0] <= i:
			cur = min(cur, ans[p][1])
			p += 1
		print(-1 if cur == int(1000000000.0) else cur, end='')
		print(end=' ' if i != n - 1 else '')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = [[-1] for i in range(n)]
	ans = []
	cursz = n
	for i in range(n):
		l[a[i] - 1].append(i)
	for i in range(n):
		if cursz == 0 or len(ans) == n:
			break
		mxdiff = -1
		if len(l[i]) == 1:
			continue
		else:
			l[i].append(n)
			for j in range(len(l[i]) - 1):
				mxdiff = max(mxdiff, l[i][j + 1] - l[i][j])
			if mxdiff <= cursz:
				for j in range(cursz - mxdiff + 1):
					ans.append(i + 1)
				cursz = mxdiff - 1
	for i in range(n - len(ans)):
		print(-1, end=' ')
	for i in range(len(ans) - 1, -1, -1):
		print(ans[i], end=' ')
	print()


from math import sqrt, ceil
from collections import defaultdict

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	hash = defaultdict(list)
	for i in range(n):
		hash[l[i]].append(i + 1)
	if len(set(l)) == 1:
		print(*[min(l)] * n)
		return
	ans = defaultdict(lambda : 10 ** 18)
	for i in hash:
		prev = 0
		maxi = -10 ** 18
		for j in hash[i]:
			z = j - prev
			maxi = max(maxi, z)
			prev = j
		z = n - prev + 1
		maxi = max(maxi, z)
		ans[maxi] = min(i, ans[maxi])
	fin = [-1]
	for i in range(1, n):
		if ans[i + 1] != 10 ** 18:
			if fin[i - 1] == -1:
				fin.append(ans[i + 1])
			else:
				fin.append(min(fin[i - 1], ans[i + 1]))
		elif fin[i - 1] == -1:
			fin.append(-1)
		else:
			fin.append(fin[i - 1])
	print(*fin)
t = int(input())
for _ in range(t):
	solve()


import sys
from collections import defaultdict
if len(sys.argv) >= 2 and sys.argv[1] == 'LOCAL':
	sys.stdin = open('input.txt')
	sys.stdout = open('output.txt', 'w')
input = sys.stdin.readline
output = sys.stdout.write
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	res = [n + 1] * (n + 1)
	occurs = defaultdict(list)
	for i in range(n):
		occurs[arr[i]].append(i + 1)
	maxAway = [0] * (n + 1)
	for i in range(1, n + 1):
		l = occurs[i]
		mx = 0
		if len(l) == 0:
			continue
		for j in range(len(l)):
			if j == 0:
				mx = max(mx, l[j])
			if j == len(l) - 1:
				mx = max(mx, n - l[j] + 1)
				mx = max(mx, l[j] - l[j - 1])
			if j >= 1:
				mx = max(mx, l[j] - l[j - 1])
		res[mx] = min(res[mx], i)
	best = n + 1
	for i in range(1, n + 1):
		if res[i] == n + 1:
			if best != n + 1:
				output(str(best) + ' ')
			else:
				output('-1' + ' ')
		else:
			best = min(best, res[i])
			output(str(best) + ' ')
	output('\n')


for x in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	d = {}
	ind = {}
	for i in range(n):
		if m[i] in d:
			d[m[i]] = max(d[m[i]], i - ind[m[i]])
			ind[m[i]] = i
		else:
			ind[m[i]] = i
			d[m[i]] = i + 1
	for i in range(n):
		if ind[m[i]] == i:
			d[m[i]] = max(d[m[i]], n - i)
	a = [float('inf')] * n
	for i in d:
		a[d[i] - 1] = min(a[d[i] - 1], i)
	for i in range(1, n):
		a[i] = min(a[i], a[i - 1])
	for i in range(n):
		if a[i] == float('inf'):
			a[i] = -1
	print(*a)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	(f, last, ans) = ([0] * (n + 1), [-1] * (n + 1), [-1] * (n + 1))
	for (i, a) in enumerate(A):
		f[a] = max(f[a], i - last[a])
		last[a] = i
	for a in range(1, n + 1):
		f[a] = max(f[a], n - last[a])
	best = [n + 1] * (n + 1)
	for a in range(1, n + 1):
		if f[a] <= n:
			best[f[a]] = min(best[f[a]], a)
	cur = n + 1
	for i in range(1, n + 1):
		cur = min(cur, best[i])
		if cur <= n:
			ans[i] = cur
	ans = ans[1:]
	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')

def prime_factors(x):
	s = set()
	n = x
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			s.add(i)
		i += 1
	if n > 1:
		s.add(n)
	return s
from collections import Counter
import heapq
from collections import Counter
from bisect import bisect_right
import heapq
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	v = [-1] * (n + 5)
	d = {}
	ans = [-1] * (n + 2)
	for i in range(n):
		if v[arr[i]] != -1:
			if arr[i] in d:
				d[arr[i]] = max(d[arr[i]], i + 1 - v[arr[i]])
				v[arr[i]] = i + 1
			else:
				d[arr[i]] = max(v[arr[i]], i + 1 - v[arr[i]])
				v[arr[i]] = i + 1
		else:
			v[arr[i]] = i + 1
	for i in range(n):
		if v[arr[i]] != -1:
			if arr[i] in d:
				d[arr[i]] = max(d[arr[i]], n + 1 - v[arr[i]])
			else:
				d[arr[i]] = max(v[arr[i]], n + 1 - v[arr[i]])
		cnt = d[arr[i]]
		if ans[cnt] == -1:
			ans[cnt] = arr[i]
		else:
			ans[cnt] = min(ans[cnt], arr[i])
	value = n + 100
	for i in range(1, n + 1):
		if ans[i] != -1:
			ans[i] = min(ans[i], value)
			value = min(value, ans[i])
		elif value <= n:
			ans[i] = value
	if arr == [arr[0]] * n:
		print(*arr)
	else:
		ans[n] = min(arr)
		print(*ans[1:n + 1])


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()
		m = {}
		for i in range(n):
			if a[i] not in m:
				m[a[i]] = [0]
			m[a[i]].append(i + 1)
		ans = [inf] * (n + 1)
		for i in m.keys():
			x = m[i]
			mxdiff = 0
			x.append(n + 1)
			for j in range(1, len(x)):
				mxdiff = max(mxdiff, x[j] - x[j - 1])
			ans[mxdiff] = min(ans[mxdiff], i)
		res = []
		x = inf
		for i in range(1, n + 1):
			x = min(x, ans[i])
			if x == inf:
				res.append(-1)
			else:
				res.append(x)
		print(*res)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	last = [-1 for _ in range(n)]
	maxlen = [-1 for _ in range(n)]
	for i in range(n):
		x = a[i] - 1
		maxlen[x] = max(maxlen[x], i - last[x])
		last[x] = i
	maxlen = [max(maxlen[i], n - last[i]) for i in range(n)]
	sol = [-1 for _ in range(n + 2)]
	for i in range(n):
		if sol[maxlen[i]] == -1:
			sol[maxlen[i]] = i + 1
	sol = sol[1:len(sol) - 1]
	if sol[0] == -1:
		sol[0] = n + 2
	for i in range(1, n):
		if sol[i] == -1:
			sol[i] = n + 2
		sol[i] = min(sol[i], sol[i - 1])
	for i in range(n):
		if sol[i] == n + 2:
			sol[i] = -1
		else:
			break
	print(' '.join([str(i) for i in sol]))


T = int(input())
while T > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	dis = [0] * n
	dic = {}
	res = [-1] * n
	for i in range(n):
		tmp = arr[i] - 1
		if tmp not in dic.keys():
			dis[tmp] = max(dis[tmp], i + 1)
		else:
			dis[tmp] = max(dis[tmp], i - dic[tmp])
		dic[tmp] = i
	for key in dic.keys():
		dis[key] = max(dis[key], n - dic[key])
	prev = n
	for i in range(n):
		if dis[i] == 0:
			continue
		else:
			start = dis[i] - 1
			temp = start
			while start < prev:
				res[start] = i + 1
				start += 1
			prev = min(prev, temp)
	print(*res)
	T -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ind = [[] for i in range(n)]
	for i in range(n):
		ind[a[i] - 1].append(i)
	freq = [int(100000000.0)] * n
	for i in range(n):
		if ind[i] == []:
			continue
		mx = 0
		start = -1
		for j in range(len(ind[i])):
			mx = max(mx, ind[i][j] - start)
			start = ind[i][j]
		mx = max(mx, n - start)
		freq[mx - 1] = min(freq[mx - 1], i + 1)
	for i in range(n):
		if freq[i] < int(100000000.0):
			start = i
			break
		freq[i] = -1
	m = 100000000.0
	for i in range(start, n):
		m = min(m, freq[i])
		freq[i] = m
	print(*freq)