Permutation $p$ is a sequence of integers $p=[p_1, p_2, \dots, p_n]$, consisting of $n$ distinct (unique) positive integers between $1$ and $n$, inclusive. For example, the following sequences are permutations: $[3, 4, 1, 2]$, $[1]$, $[1, 2]$. The following sequences are not permutations: $[0]$, $[1, 2, 1]$, $[2, 3]$, $[0, 1, 2]$.

The important key is in the locked box that you need to open. To open the box you need to enter secret code. Secret code is a permutation $p$ of length $n$. 

You don't know this permutation, you only know the array $q$ of prefix maximums of this permutation. Formally:  $q_1=p_1$,  $q_2=\max(p_1, p_2)$,  $q_3=\max(p_1, p_2,p_3)$,  ...  $q_n=\max(p_1, p_2,\dots,p_n)$. 

You want to construct any possible suitable permutation (i.e. any such permutation, that calculated $q$ for this permutation is equal to the given array).


-----Input-----

The first line contains integer number $t$ ($1 \le t \le 10^4$) — the number of test cases in the input. Then $t$ test cases follow.

The first line of a test case contains one integer $n$ $(1 \le n \le 10^{5})$ — the number of elements in the secret code permutation $p$.

The second line of a test case contains $n$ integers $q_1, q_2, \dots, q_n$ $(1 \le q_i \le n)$ — elements of the array $q$ for secret permutation. It is guaranteed that $q_i \le q_{i+1}$ for all $i$ ($1 \le i < n$).

The sum of all values $n$ over all the test cases in the input doesn't exceed $10^5$.


-----Output-----

For each test case, print:  If it's impossible to find such a permutation $p$, print "-1" (without quotes).  Otherwise, print $n$ distinct integers $p_1, p_2, \dots, p_n$ ($1 \le p_i \le n$). If there are multiple possible answers, you can print any of them. 


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

Output
1 3 4 5 2 
-1
2 1 
1 



-----Note-----

In the first test case of the example answer $[1,3,4,5,2]$ is the only possible answer:  $q_{1} = p_{1} = 1$;  $q_{2} = \max(p_{1}, p_{2}) = 3$;  $q_{3} = \max(p_{1}, p_{2}, p_{3}) = 4$;  $q_{4} = \max(p_{1}, p_{2}, p_{3}, p_{4}) = 5$;  $q_{5} = \max(p_{1}, p_{2}, p_{3}, p_{4}, p_{5}) = 5$. 

It can be proved that there are no answers for the second test case of the example.

Source: codeforces | Difficulty: EASY
Tags: Constructive algorithms


Solutions:
def test(a):
	se = set()
	se.add(a[0])
	ans = [a[0]]
	l = 1
	for i in range(1, len(a)):
		if a[i] == a[i - 1]:
			while l in se:
				l += 1
			ans.append(l)
			se.add(l)
		else:
			ans.append(a[i])
			se.add(a[i])
		if ans[i] > a[i]:
			print(-1)
			return
	f = False
	if len(set(ans)) == n:
		print(' '.join(map(str, ans)))
	else:
		print(-1)
	return
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	test(a)


t = int(input())
for _ in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	ans = [0 for _ in range(n)]
	ans[0] = q[0]
	s = set(range(1, max(q) + 1))
	s -= {q[0]}
	tr = False
	for i in range(1, n):
		if q[i - 1] == q[i]:
			for j in s:
				if j < q[i]:
					ans[i] = j
					s -= {j}
					break
			else:
				tr = True
				break
		elif q[i - 1] < q[i]:
			ans[i] = q[i]
			if q[i] in s:
				s -= {q[i]}
			else:
				tr = True
				break
	if tr:
		print('-1')
	else:
		print(*ans)


t = int(input())
for z in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ret = [0 for i in range(n)]
	was = set()
	can = set([i for i in range(1, n + 1)])
	for i in range(n):
		x = arr[i]
		if not x in was:
			ret[i] = x
			was.add(x)
	left = sorted(list(can - was), reverse=True)
	for i in range(n):
		if not left:
			break
		x = left[-1]
		if not ret[i]:
			ret[i] = x
			left.pop()
	mx = ret[0]
	flag = True
	for i in range(n):
		mx = max(mx, ret[i])
		if mx != arr[i]:
			flag = False
			break
	if flag:
		print(*ret)
	else:
		print(-1)


for i in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	ss = [0] * n
	ans = b[:]
	maxx = b[0]
	for i in range(n):
		ss[b[i] - 1] += 1
	tt = []
	y = 0
	for i in range(n):
		if ss[i] == 0:
			tt.append(i + 1)
	mm = len(tt)
	x = True
	for i in range(1, n):
		if ans[i] > maxx:
			maxx = ans[i]
		elif ans[i] == maxx:
			if y == mm:
				print(-1)
				x = False
				break
			elif tt[y] > ans[i]:
				print(-1)
				x = False
				break
			ans[i] = tt[y]
			y += 1
		else:
			print(-1)
			x = False
			break
	if x:
		print(*ans)


import sys
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	n = inp()
	arr = list(invr())
	ans = []
	sor = []
	helper = [0] * (n + 1)
	for i in arr:
		helper[i] -= 1
	for i in range(1, n + 1):
		if helper[i] == 0:
			sor.append(i)
	ans.append(arr[0])
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			if sor[0] >= arr[i]:
				ans = -1
				print(-1)
				break
			else:
				ans.append(sor[0])
				sor.pop(0)
				continue
		ans.append(arr[i])
	if ans == -1:
		continue
	s = ''
	for i in range(n):
		s += str(ans[i]) + ' '
	print(s)


otvet = []
t = int(input())
for i in range(t):
	n = int(input())
	result = [0] * n
	q = list(map(int, input().split()))
	p = [q[0]]
	result[q[0] - 1] = 1
	rr = 0
	for j in range(1, n):
		if q[j] > q[j - 1]:
			p.append(q[j])
			result[q[j] - 1] = 1
		else:
			while result[rr] != 0 and rr + 1 < q[j]:
				rr += 1
			if rr + 1 == q[j]:
				p = [-1]
				break
			else:
				result[rr] = 1
				p.append(rr + 1)
	print(*p)


for _ in range(int(input())):
	i = int(input())
	q = list(map(int, input().split()))
	log = [0] * i
	k = [0] * i
	j = 0
	p = 0
	for x in range(i):
		if q[x] < x + 1:
			k = [-1]
			break
		if q[x] == p:
			while True:
				if log[j] == 1:
					j += 1
				else:
					break
			log[j] = 1
			k[x] = j + 1
		else:
			k[x] = q[x]
			log[q[x] - 1] = 1
		p = q[x]
	print(*k)


for i in range(int(input())):
	z = int(input())
	q = list(map(int, input().split()))
	w = False
	for i in range(z):
		if q[i] <= i:
			w = True
	if w:
		print(-1)
		continue
	h = [0] * z
	h[q[0] - 1] = 1
	a = 0
	ans = [q[0]]
	for i in range(1, z):
		if q[i] == q[i - 1]:
			while h[a] != 0:
				a += 1
			h[a] = 1
			a += 1
			ans.append(a)
		else:
			h[q[i] - 1] = 1
			ans.append(q[i])
	print(*ans)


from collections import deque
for i in range(int(input())):
	n = int(input())
	h = deque([i + 1 for i in range(n)])
	used = [False] * n
	ans = [0] * n
	c = list(map(int, input().split()))
	ans[0] = c[0]
	used[c[0] - 1] = True
	f = True
	for i in range(n):
		if i + 1 > c[i]:
			f = False
	if not f:
		print(-1)
		continue
	for i in range(n - 1):
		if c[i + 1] != c[i]:
			ans[i + 1] = c[i + 1]
		else:
			x = h.popleft()
			while used[x - 1]:
				x = h.popleft()
			ans[i + 1] = x
		used[ans[i + 1] - 1] = True
	print(*ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	q = -1
	t = 0
	r = []
	for i in range(n):
		if a[i] < q or a[i] < i + 1:
			t = 1
			break
		else:
			q = a[i]
	if t == 1:
		print(-1)
	else:
		q = -1
		w = [True] * n
		z = 0
		for i in range(n):
			if a[i] > q:
				r.append(a[i])
				w[a[i] - 1] = False
				q = a[i]
			else:
				while w[z] == False:
					z += 1
				r.append(z + 1)
				z += 1
		print(*r)


from heapq import *
t = int(input())
for _ in range(t):
	n = int(input())
	q = [0] + list(map(int, input().split()))
	m = 1
	used = [False] * (n + 1)
	p = [0] * (n + 1)
	for i in range(1, n + 1):
		if not used[q[i]]:
			used[q[i]] = True
			p[i] = q[i]
		else:
			while used[m]:
				m += 1
			if m > q[i]:
				p = [0, -1]
				break
			else:
				used[m] = True
				p[i] = m
	print(*p[1:])


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	used = []
	for i in range(n):
		used.append(False)
	p = [str(a[0])]
	used[a[0] - 1] = True
	ans = 1
	now = 0
	for i in range(1, n):
		while now < n and used[now]:
			now += 1
		if a[i] > a[i - 1]:
			p.append(str(a[i]))
			if used[a[i] - 1]:
				ans = 0
				break
			used[a[i] - 1] = True
		else:
			if now + 1 > a[i] or used[now]:
				ans = 0
				break
			used[now] = True
			p.append(str(now + 1))
	if ans:
		print(' '.join(p))
	else:
		print(-1)


m = int(input())
for j in range(m):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	used = [0] * (n + 1)
	t = 1
	b.append(a[0])
	f = True
	used[a[0]] = 1
	for k in range(1, n):
		if a[k] == a[k - 1]:
			while used[t] == 1:
				t += 1
			if t < a[k - 1]:
				b.append(t)
				used[t] = 1
				t += 1
			else:
				f = False
				break
		elif a[k] > a[k - 1]:
			b.append(a[k])
			used[a[k]] = 1
		else:
			f = False
			break
	if f:
		print(*b)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	high = 0
	alo = set()
	p = []
	for i in range(n):
		if q[i] > high:
			p.append(q[i])
			for j in range(high + 1, q[i]):
				alo.add(j)
			high = q[i]
		elif len(alo) > 0:
			p.append(alo.pop())
		else:
			print(-1)
			break
	else:
		for i in range(n):
			print(p[i], end=' ')
		print()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = [0] * n
	flag = True
	used = [False] * (n + 1)
	b = -1
	j = 1
	for i in range(n):
		if l[i] != b:
			ans[i] = l[i]
		else:
			while j <= n and used[j]:
				j += 1
			ans[i] = j
		if ans[i] > l[i]:
			flag = False
			break
		used[ans[i]] = True
		b = l[i]
	if not flag:
		print('-1')
	else:
		print(' '.join([str(p) for p in ans]))


for _ in ' ' * int(input()):
	a = int(input())
	b = list(map(int, input().split()))
	z = [0] * (a + 1)
	k = [0] * a
	pre = 0
	j = 1
	for i in range(a):
		if z[b[i]] == 0:
			z[b[i]] = 1
			k[i] = b[i]
		else:
			while z[j]:
				j += 1
			k[i] = j
			z[j] = 1
			if k[i] > b[i]:
				k = [-1]
				break
		pre = b[i]
	print(*k)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	a = defaultdict(int)
	temp1 = []
	ans = []
	for i in range(len(q)):
		if q[i] <= i:
			print(-1)
			break
		a[q[i]] += 1
	else:
		for i in range(1, n + 1):
			if a[i] == 0:
				temp1.append(i)
		for i in range(len(q) - 1):
			if q[i] == q[i + 1]:
				ans.append(i + 1)
		for i in range(len(ans)):
			q[ans[i]] = temp1[i]
		print(*q)


for i in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	b = [0 for i in range(n)]
	ans = []
	min = 0
	for j in range(n):
		a[j] -= 1
		if b[a[j]] == 0:
			b[a[j]] = 1
			ans.append(a[j] + 1)
		else:
			t = 0
			for q in range(min, n):
				if b[q] == 0:
					t = q
					min = q
					break
			if t > a[j]:
				print(-1)
				break
			else:
				b[t] = 1
				ans.append(t + 1)
	if len(ans) == n:
		print(*ans)


t = int(input())
answer = []
for j in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	d = set((i for i in range(1, n + 1)))
	z = True
	ans = [0] * n
	for i in range(n):
		if i == 0 or q[i] > q[i - 1]:
			if not z:
				break
			ans[i] = q[i]
			if q[i] in d:
				d.remove(q[i])
			else:
				z = False
		elif q[i] < q[i - 1]:
			t = False
	d = list(d)
	d.sort(reverse=True)
	for i in range(n):
		if not z:
			break
		if ans[i] == 0:
			if len(d) > 0 and d[-1] < q[i]:
				ans[i] = d.pop(-1)
			else:
				z = False
	if z:
		answer += [' '.join(map(str, ans))]
	else:
		answer += ['-1']
print('\n'.join(answer))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	res = [l[0]]
	m = 1
	d = {l[0]: 1}
	xf = 0
	for i in range(1, n):
		if l[i] != l[i - 1]:
			res.append(l[i])
			d[l[i]] = 1
		else:
			while m in d:
				m += 1
			if m < l[i]:
				res.append(m)
				d[m] = 1
			else:
				print(-1)
				break
	else:
		print(*res)


from collections import deque
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	q = [True] * (n + 1)
	q[0] = False
	ans = [-1] * n
	ans[0] = l[0]
	q[l[0]] = False
	for i in range(1, n):
		if l[i] > l[i - 1]:
			ans[i] = l[i]
			q[l[i]] = False
	z = deque()
	r = True
	for i in range(n):
		if q[i]:
			z.append(i)
	for i in range(n):
		if ans[i] == -1:
			if z:
				ans[i] = z.popleft()
			else:
				r = False
				break
	if r == False:
		print(-1)
	else:
		y = [-1] * n
		y[0] = ans[0]
		for i in range(1, n):
			y[i] = max(y[i - 1], ans[i])
		if y == l:
			print(*ans)
		else:
			print(-1)


import sys, heapq
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	ans = [0] * n
	check = [True] * (n + 1)
	first = dict().fromkeys(set(arr), 9876543210)
	q = []
	for i in range(n):
		first[arr[i]] = min(first[arr[i]], i)
	for i in range(n):
		if i == first[arr[i]]:
			ans[i] = arr[i]
			check[arr[i]] = False
	for i in range(1, n + 1):
		if check[i]:
			heapq.heappush(q, i)
	for i in range(n):
		if not ans[i]:
			ans[i] = heapq.heappop(q)
	can = True
	for i in range(n):
		if ans[i] > arr[i]:
			can = False
			break
	print(' '.join(map(str, ans)) if can else -1)


t = int(input())
for adasdasdWEE in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	free = set()
	for i in range(1, n + 1):
		free.add(i)
	arr = []
	ex = 0
	arr.append(q[0])
	free.remove(q[0])
	for i in range(1, n):
		el = q[i]
		if ex:
			break
		if el == arr[i - 1]:
			for new in free:
				if new <= el:
					arr.append(new)
					free.remove(new)
					break
			else:
				print(-1)
				ex = 1
				break
		elif el in free:
			arr.append(el)
			free.remove(el)
		else:
			for new in free:
				if new <= el:
					arr.append(new)
					free.remove(new)
					break
			else:
				print(-1)
				ex = 1
				break
	if not ex:
		print(*arr)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	possible = []
	used = set()
	for j in range(n):
		used.add(a[j])
	for j in range(n, 0, -1):
		if j not in used:
			possible.append(j)
	ans = [a[0]]
	breaki = False
	for j in range(1, n):
		if a[j] == a[j - 1]:
			if possible[-1] < a[j]:
				ans.append(possible.pop())
			else:
				breaki = True
				break
		elif a[j] < a[j - 1]:
			breaki = True
			break
		else:
			ans.append(a[j])
	if breaki:
		print(-1)
	else:
		print(' '.join(map(str, ans)))


for __ in range(int(input())):
	n = int(input())
	ar1 = list(map(int, input().split()))
	ar = ar1.copy()
	lol = set()
	for j in range(1, n + 1):
		lol.add(j)
	lol.discard(ar[0])
	for i in range(1, n):
		if ar1[i] > ar1[i - 1]:
			lol.discard(ar1[i])
		else:
			ar[i] = 0
	kek = list(lol)
	kek.sort()
	num = 0
	flag = 0
	for j in range(n):
		if ar[j] == 0:
			ar[j] = kek[num]
			num += 1
		if ar[j] > ar1[j]:
			flag = 1
	if flag == 1:
		print(-1)
	else:
		print(*ar)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	arr = [0 for j in range(n)]
	pos = 0
	arr[l[0] - 1] = 1
	final = [l[0]]
	flag = 0
	for j in range(1, n):
		if l[j] != l[j - 1]:
			arr[l[j] - 1] = 1
			final.append(l[j])
		else:
			while arr[pos] != 0:
				pos += 1
			if pos + 1 <= l[j]:
				arr[pos] = 1
				final.append(pos + 1)
			else:
				flag = 1
				break
	if flag == 1:
		print(-1)
	else:
		print(*final, sep=' ')


for _ in range(int(input())):
	f = int(input())
	d = [int(i) for i in input().split()]
	k = []
	g = []
	dict1 = {}
	case = True
	for i in range(f):
		if dict1.get(d[i]) == None:
			dict1[d[i]] = 1
			g.append(d[i])
			if d[i] != i + 1 and dict1.get(i + 1) == None:
				k.append(i + 1)
		else:
			if dict1.get(i + 1) == None:
				dict1[i + 1] = 1
				k.append(i + 1)
			case = False
			if k == []:
				print(-1)
				break
			if k[0] >= d[i]:
				print(-1)
				break
			else:
				dict1[k[0]] = 1
				g.append(k[0])
				k.remove(k[0])
				case = True
	if case:
		print(*g)


from collections import deque
I = input
IN = lambda x: map(int, x.split())
L = lambda x: list(IN(x))
for _ in range(int(I())):
	n = int(I())
	q = L(I())
	k = []
	f = deque()
	mx = 0
	z = 0
	flag = True
	for i in q:
		if i > mx:
			for j in range(mx + 1, i):
				f.append(j)
			mx = i
			k.append(i)
		else:
			if z == mx:
				flag = False
				break
			k.append(f.pop())
		z += 1
	if flag:
		print(*k)
	else:
		print(-1)


t = int(input())
for faw in range(t):
	n = int(input())
	a = [0] + list(map(int, input().split()))
	nun = []
	ans = []
	f = True
	for i in range(1, n + 1):
		if a[i] == a[i - 1]:
			if len(nun) == 0:
				f = False
				break
			else:
				ans.append(nun.pop())
		else:
			ans.append(a[i])
			for i in range(a[i - 1] + 1, a[i]):
				nun.append(i)
	if f:
		print(*ans)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	b = [0] * n
	g = 1
	s = set()
	s.add(q[0])
	b[0] = q[0]
	m = b[0]
	f = True
	for j in range(1, n):
		if q[j] > q[j - 1]:
			b[j] = q[j]
			s.add(b[j])
			m = b[j]
		else:
			while g in s:
				g += 1
			if g < m:
				b[j] = g
				g += 1
			else:
				f = False
	if f:
		print(*b)
	else:
		print(-1)


from sys import stdin

def main():
	cases = int(stdin.readline())
	for _ in range(cases):
		n = int(stdin.readline())
		l = list(map(int, stdin.readline().split()))
		ans = l[:]
		rep1 = [0 for _ in range(n + 1)]
		rep2 = list()
		flag = True
		for i in range(n):
			u = l[i]
			if 0 < u <= n:
				rep1[u] += 1
			else:
				flag = False
				break
		for k in range(1, n):
			if not rep1[k]:
				rep2.append(k)
		rep2.sort(reverse=True)
		for j in range(1, n):
			if l[j] == l[j - 1]:
				if len(rep2):
					x = rep2.pop()
					if x < l[j]:
						ans[j] = x
					else:
						flag = False
						break
				else:
					flag = False
					break
		if flag and (not len(rep2)):
			for k in range(n - 1):
				print(ans[k], end=' ')
			print(ans[-1])
		else:
			print(-1)
main()


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mydick = dict()
	mydick = defaultdict(lambda : 0, mydick)
	for i in a:
		mydick[i] = 1
	l = []
	for i in range(1, n + 1):
		if mydick[i] == 0:
			l.append(i)
	j = 0
	ok = True
	ans = []
	ans.append(a[0])
	for i in range(1, n):
		if a[i] == a[i - 1]:
			if l[j] < a[i]:
				ans.append(l[j])
				j += 1
			else:
				ok = False
				break
		else:
			ans.append(a[i])
	if ok:
		print(*ans)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	used = set()
	ans = []
	used.add(q[0])
	ans.append(q[0])
	cnt = 1
	flag = False
	for i in range(1, n):
		if q[i] == q[i - 1]:
			while cnt in used:
				cnt += 1
			used.add(cnt)
			if q[i] > cnt:
				ans.append(cnt)
			else:
				flag = True
				break
		else:
			used.add(q[i])
			ans.append(q[i])
	if flag:
		print(-1)
	else:
		print(*ans)


a = int(input())
for i in range(a):
	b = int(input())
	l = list(map(int, input().split()))
	k = []
	t = [i for i in range(b + 1)]
	k.append(l[0])
	last = k[0]
	j = 0
	t[last] = 0
	for i in l[1:]:
		if i != last:
			last = i
			k.append(last)
			t[last] = 0
		else:
			while t[j] == 0:
				j += 1
			k.append(t[j])
			j += 1
	ch = [k[0]]
	for i in k[1:]:
		ch.append(max(ch[-1], i))
	if l != ch:
		print(-1)
	else:
		print(*k)


t = int(input())
for _ in range(t):
	n = int(input())
	v = list(map(int, input().split()))
	tmp = v
	tmp.sort()
	if tmp != v:
		print(-1)
		continue
	u = [0 for _ in range(n + 1)]
	l = 1
	ans = []
	last = 0
	for i in v:
		if i == last:
			while u[l] == 1:
				l += 1
			if l > i:
				break
			else:
				ans.append(l)
				l += 1
		else:
			ans.append(i)
			u[i] = 1
		last = i
	if len(ans) != n:
		print(-1)
	else:
		print(*ans)


for _ in range(int(input())):
	n = int(input())
	x = 0
	a = []
	b = []
	for y in map(int, input().split()):
		if y < x:
			print(-1)
			break
		elif y > x:
			while x < y:
				x += 1
				a += (x,)
			b += (a.pop(),)
		elif a:
			b += (a.pop(),)
		else:
			print(-1)
			break
	else:
		print(' '.join(map(str, b)))


t = int(input())
for x in range(t):
	n = int(input())
	q = [-1]
	q += list(map(int, input().split()))
	p = [-1 for i in range(n + 1)]
	freq = {i: -1 for i in range(1, n + 1)}
	for i in range(1, n + 1):
		freq[q[i]] = 1
	p[1] = q[1]
	for i in range(2, n + 1):
		if q[i] != q[i - 1]:
			p[i] = q[i]
	v = []
	for i in range(1, n + 1):
		if freq[i] == -1:
			v.append(i)
	c = 0
	for i in range(1, n + 1):
		if p[i] == -1:
			p[i] = v[c]
			c += 1
	c_p = [0, p[1]] + [x for x in range(2, n + 1)]
	flag = 0
	for i in range(2, n + 1):
		c_p[i] = max(c_p[i - 1], p[i])
		if c_p[i] != q[i]:
			flag = 1
			break
	if flag == 1:
		print(-1)
	else:
		for i in p[1:]:
			print(i, end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	q = [int(x) for x in input().strip().split()]
	boo = [True] * (n + 1)
	p = [0] * n
	p[0] = q[0]
	boo[q[0] - 1] = False
	for j in range(1, n):
		if q[j] != q[j - 1]:
			p[j] = q[j]
			boo[q[j] - 1] = False
		else:
			p[j] = -q[j]
	j = 0
	g = 0
	a = 0
	while not boo[j]:
		j += 1
	while j < n:
		w = 0
		while p[g] > 0:
			g += 1
			if g == n:
				w = 1
				break
		if w == 1:
			break
		if j + 1 < -p[g]:
			p[g] = j + 1
			boo[j] = False
		else:
			a = 1
			break
		while not boo[j]:
			j += 1
	if a == 0:
		print(*p)
	else:
		print(-1)


import collections
for _ in range(int(input())):
	n = int(input())
	q = [int(i) for i in input().split()]
	deq = collections.deque()
	start = 1
	secret_code = []
	flag = 0
	for (ind, q_i) in enumerate(q):
		if ind != 0:
			if q_i > q[ind - 1]:
				for num in range(q[ind - 1] + 1, q_i):
					deq.append(num)
				secret_code.append(q_i)
			elif q_i == q[ind - 1]:
				if len(deq) == 0:
					flag = 1
					break
				else:
					secret_code.append(deq.popleft())
		else:
			for num in range(1, q_i):
				deq.append(num)
			secret_code.append(q_i)
	print(*(secret_code if flag == 0 else [-1]))


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = [a[0]]
	m = 1
	d = {a[0]: 1}
	flag = 0
	for i in range(1, n):
		if a[i] != a[i - 1]:
			ans.append(a[i])
			d[a[i]] = 1
		else:
			while m in d:
				m += 1
			if m >= a[i]:
				flag = 1
				break
			ans.append(m)
			d[m] = 1
	if flag:
		print(-1)
		continue
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	res = [a[0]]
	skip = set(range(1, res[-1]))
	for i in range(1, n):
		if a[i] > a[i - 1]:
			res.append(a[i])
			skip |= set(range(a[i - 1] + 1, a[i]))
		elif skip:
			res.append(skip.pop())
		else:
			res = [-1]
			break
	print(*res)


for _ in range(int(input())):
	n = int(input())
	q = [int(i) for i in input().split()]
	ans = 0
	for i in range(1, n):
		if i + 1 > q[i]:
			print(-1)
			ans = -1
			break
	if ans == 0:
		a = [0 for i in range(n)]
		k = 0
		print(q[0], end=' ')
		a[q[0] - 1] = 1
		for i in range(1, n):
			if q[i - 1] == q[i]:
				while a[k] == 1:
					k += 1
				print(k + 1, end=' ')
				a[k] = 1
			else:
				print(q[i], end=' ')
				a[q[i] - 1] = 1
		print()


t = int(input())
for i in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	used = {q[0]: True}
	seq = [q[0]]
	ks = 1
	for j in range(1, n):
		if q[j] == q[j - 1]:
			for k in range(ks, q[j]):
				if used.get(k) is None:
					seq.append(k)
					used[k] = True
					ks = k + 1
					break
			else:
				print(-1)
				break
		else:
			used[q[j]] = True
			seq.append(q[j])
	else:
		print(*seq)


a = int(input())
Ans = []
for i in range(a):
	B = []
	x = int(input())
	A = list(map(int, input().split()))
	C = []
	for j in range(1, len(A) + 1):
		C.append([j, 0])
	k = 1
	n = 0
	for j in range(len(A)):
		if A[j] > k:
			B.append(A[j])
			k = A[j]
			C[A[j] - 1][1] = 1
		else:
			while C[n][1] == 1:
				n += 1
			C[n][1] = 1
			B.append(n + 1)
	b0 = B[0]
	Tr = True
	for j in range(len(B)):
		b0 = max(b0, B[j])
		if A[j] != b0:
			Tr = False
	if Tr:
		Ans.append(B)
	else:
		Ans.append([-1])
for b in Ans:
	print(*b)


kT = int(input())
ans = []
for iter in range(kT):
	n = int(input())
	q = list(map(int, input().split()))
	ans.append([q[0]])
	valid = [1] * (n + 1)
	valid[q[0]] = 0
	last = 1
	while not valid[last] and last != n:
		last += 1
	for i in range(1, n):
		if q[i] > q[i - 1]:
			ans[iter].append(q[i])
			valid[q[i]] = 0
			while not valid[last] and last != n:
				last += 1
		elif q[i] == q[i - 1]:
			if last < q[i]:
				ans[iter].append(last)
				valid[last] = 0
				last += 1
				while not valid[last] and last != n:
					last += 1
			else:
				ans[iter] = [-1]
				break
		else:
			ans[iter] = [-1]
			break
for line in ans:
	print(*line)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(flag, flag1) = (0, 0)
	k = 1
	m = max(l)
	s = {x: 0 for x in range(1, m + 1)}
	l2 = []
	l2.append(l[0])
	s[l2[0]] = 1
	for i in range(1, len(l)):
		flag1 = 0
		if l[i] > l[i - 1]:
			l2.append(l[i])
			s[l[i]] = 1
		elif k < l[i]:
			for j in range(k, l[i] + 1):
				if s[j] == 0:
					flag1 = 1
					s[j] = 1
					k = j
					l2.append(j)
					break
			if flag1 == 0:
				print(-1)
				flag = 1
				break
		else:
			print(-1)
			flag = 1
			break
	if flag == 0:
		print(*l2)


I = input
for _ in range(int(I())):
	try:
		t = 0
		n = int(input())
		a = list(map(int, I().split(' ')))
		a1 = [0 for i in range(n + 1)]
		p = [str(a[0])]
		a1[a[0]] = 1
		for i in range(1, n):
			if a[i] == a[i - 1]:
				for j in range(t + 1, n + 1):
					if a1[j] == 0:
						t = j
						break
				if t > a[i]:
					assert 1 == 0
				p.append(str(t))
				a1[t] = 1
			else:
				a1[a[i]] = 1
				p.append(str(a[i]))
		print(' '.join(p))
	except AssertionError:
		print('-1')


check = set()
q = int(input())
maxy = 0
ans = []
for _ in range(q):
	k = int(input())
	A = list(map(int, input().split()))
	for i in A:
		if i > maxy:
			for j in range(maxy + 1, i):
				check.add(j)
			ans.append(i)
			maxy = i
		else:
			if not check:
				print('-1')
				maxy = 0
				ans = []
				break
			ans.append(check.pop())
	else:
		print(*ans)
		maxy = 0
		ans = []
		check = set()


n = int(input())
ans = []
for i in range(n):
	m = int(input())
	ned = []
	s = list(map(int, input().split()))
	if s[0] != 1:
		s = [0] + s
	s_edit = {}
	maxim = s[0]
	for j in range(1, len(s)):
		a = s[j] - maxim
		maxim = max(maxim, s[j])
		if a == 0:
			if len(ned) == 0:
				s = [-1]
				break
			s_edit[j] = ned.pop(0)
			continue
		if a > 1:
			start = s[j - 1] + 1
			end = s[j]
			for o in range(start, end):
				ned.append(o)
	for k in range(len(s)):
		try:
			test = s_edit[k]
		except:
			test = False
		if test != False:
			s[k] = test
	ans.append(s)
for i in range(n):
	if ans[i][0] == 0:
		print(' '.join(list(map(str, ans[i][1:]))))
	else:
		print(' '.join(list(map(str, ans[i]))))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	cond = 0
	d = {}
	e = {}
	for i in range(n):
		if d.get(a[i]) == None:
			d[a[i]] = 1
		else:
			d[a[i]] += 1
	i = 0
	cond1 = 0
	k = 1
	while i < n:
		if d[a[i]] <= a[i]:
			b.append(a[i])
			e[a[i]] = 1
			o = d[a[i]]
			d[a[i]] -= 1
			while d[a[i]] != 0:
				if e.get(k) == None:
					b.append(k)
					e[k] = 1
					d[a[i]] -= 1
				k += 1
				if k > a[i]:
					cond1 = 1
					break
			i += o
			if cond1:
				cond = 1
				break
		else:
			cond = 1
			break
	if cond:
		print(-1)
	else:
		print(*b)


setP = [False] * (10 ** 5 + 1)
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		setP[i] = False
	notFound = False
	left = 1
	answer = []
	prev = -1
	for i in range(n):
		curr = a[i]
		if len(answer) == 0:
			setP[curr - 1] = True
			answer.append(curr)
		elif prev < curr:
			setP[curr - 1] = True
			answer.append(curr)
		elif prev == curr:
			while setP[left - 1] == True and left < n + 1:
				left += 1
			if left >= curr:
				notFound = True
				break
			else:
				setP[left - 1] = True
				answer.append(left)
		prev = curr
	if notFound:
		print(-1)
	else:
		print(' '.join([str(x) for x in answer]))


for _ in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	p = 0
	cnt = 1
	ans = [0] * n
	s = {}
	test = 0
	for i in range(n):
		if m[i] != p:
			p = m[i]
			s[p] = 1
			ans[i] = p
		elif m[i] < cnt:
			print(-1)
			test = 1
			break
		cnt += 1
	if test:
		continue
	cnt = 1
	for i in range(n):
		if not ans[i]:
			while s.get(cnt):
				cnt += 1
			ans[i] = cnt
			cnt += 1
	print(*ans)


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 ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
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

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))
mod = 1000000007

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

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

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

class MergeFind:

	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 lcm(a, b):
	return abs(a // gcd(a, b) * b)

def comb(n, r):
	if n < r:
		return 0
	else:
		return fac[n] * (finv[r] * finv[n - r] % mod) % mod

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 fsep():
	return map(float, inp().split())

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

def arr1d(n, v):
	return [v] * n

def arr2d(n, m, v):
	return [[v] * m for _ in range(n)]

def arr3d(n, m, p, v):
	return [[[v] * p for _ in range(m)] for i in range(n)]

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

def solve():
	n = N()
	ar = lis()
	ran = deque(range(1, n + 1))
	s = set(range(1, n + 1))
	ans = []
	pm = -1
	for i in ar:
		if i > pm:
			if i in s:
				ans.append(i)
				s.remove(i)
				pm = i
			else:
				print(-1)
				return
			continue
		if i < pm:
			print(-1)
			return
		if i == pm:
			while 1:
				t = ran.popleft()
				if t in s:
					s.remove(t)
					break
			if t <= pm:
				ans.append(t)
			else:
				print(-1)
				return
	print(*ans)
testcase(int(inp()))


def solve1(n, ql):
	pl = [0] * n
	ss = set((i for i in range(1, n + 1)))
	r = True
	for i in range(n):
		if i == 0 or ql[i] > ql[i - 1]:
			if not r:
				break
			pl[i] = ql[i]
			if ql[i] in ss:
				ss.remove(ql[i])
			else:
				r = False
	ss = list(ss)
	ss.sort(reverse=True)
	for i in range(n):
		if not r:
			break
		if pl[i] == 0:
			if len(ss) > 0 and ss[-1] < ql[i]:
				pl[i] = ss.pop(-1)
			else:
				r = False
	if r:
		print(' '.join((str(p) for p in pl)))
	else:
		print('-1')

def solve():
	t = int(input())
	for i in range(t):
		n = int(input())
		ql = [int(s) for s in input().split()]
		solve1(n, ql)
solve()


for i in range(int(input())):
	c = 1
	n = int(input())
	s = [int(i) for i in input().split()]
	d = [s[0]]
	b = set(s)
	a = [i for i in range(1, n + 1) if i not in b]
	for i in range(1, n):
		if s[i - 1] != s[i]:
			d.append(s[i])
		else:
			d.append(0)
	b = 0
	for i in range(n):
		if d[i] == 0:
			d[i] = a[b]
			b += 1
	for i in range(n):
		if d[i] > s[i]:
			c = 0
			break
	if c:
		print(*d)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [0] * n
	m = 0
	c = set(range(1, n + 1))
	for i in range(n):
		if a[i] > m:
			b[i] = a[i]
			m = a[i]
			c.discard(a[i])
	c = sorted(c)
	j = 0
	for i in range(n):
		if b[i] == 0:
			b[i] = c[j]
			j += 1
			if b[i] > a[i]:
				print(-1)
				break
	else:
		print(*b)


for i in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = 0
	if len(l) == 1:
		print(l[0])
	else:
		for j in range(0, n):
			if l[j] <= j:
				print(-1)
				f = 1
				break
		if f != 1:
			l2 = []
			for j in range(0, n):
				l2.append(0)
			for j in range(0, n):
				l2[l[j] - 1] += 1
			np = []
			for j in range(n - 1, -1, -1):
				if l2[j] == 0:
					np.append(j + 1)
			k = 0
			for j in range(n - 1, -1, -1):
				if l[j] == l[j - 1]:
					l[j] = np[k]
					k += 1
			for j in l:
				print(j, end=' ')
			print()


def solve():
	am = int(input())
	arr = list(map(int, input().split()))
	was = [False] * am
	out = [-1] * am
	l = -99
	c = [0] * am
	for i in range(am):
		c[arr[i] - 1] += 1
		if l != arr[i]:
			l = arr[i]
			was[arr[i] - 1] = True
			out[i] = l
	for i in range(am):
		if arr[i] < i + 1:
			print(-1)
			return 0
	m = am - 1
	for i in range(am - 1, -1, -1):
		if out[i] == -1:
			ind = m
			while was[ind]:
				ind -= 1
			was[ind] = True
			m = ind
			out[i] = ind + 1
	print(*out)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = [0] * n
	used = [False] * (n + 1)
	ans[0] = a[0]
	used[a[0]] = True
	lst = 1
	ok = True
	for i in range(1, n):
		if a[i] > a[i - 1]:
			ans[i] = a[i]
			used[a[i]] = True
		elif a[i] < a[i - 1]:
			print(-1)
			ok = False
			break
		else:
			while used[lst]:
				lst += 1
			if a[i] < lst:
				print(-1)
				ok = False
				break
			else:
				ans[i] = lst
				lst += 1
				used[ans[i]] = True
	if ok:
		for i in range(n):
			print(ans[i], end=' ')
		print()


n = int(input())
for i in range(n):
	k = int(input())
	used = [0] * k
	a = list(map(int, input().split()))
	p = 0
	ans = [0] * k
	for i in range(k):
		if a[i] != p:
			ans[i] = a[i]
			used[a[i] - 1] = 1
		p = a[i]
	t = 0
	flag = 0
	for i in range(k):
		if ans[i] == 0:
			while used[t] == 1 and t < a[i]:
				t += 1
			if t == a[i]:
				flag = 1
				break
			else:
				used[t] = 1
				ans[i] = t + 1
	if flag == 1:
		print(-1)
	else:
		print(*ans)


t = int(input())

def anakonda():
	input()
	v = list(map(lambda x: int(x), input().split()))
	c = []
	z = []
	m = 0
	k = 0
	for i in range(len(v)):
		if v[i] > m:
			z.append(v[i])
			for q in range(m + 1, v[i]):
				c.append(q)
			m = v[i]
		else:
			if k >= len(c):
				print(-1)
				return
			z.append(c[k])
			k += 1
	print(' '.join(list(map(lambda x: str(x), z))))
for _ in range(t):
	anakonda()


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY, log as LOG
from sys import stdin, stdout
INPUT = stdin.readline
PRINT = stdout.write

def player1():
	print('')

def player2():
	print('')

def isPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def factors(x):
	ans = []
	for i in range(1, MC(SQRT(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if x % (x // i) == 0:
				ans.append(x // i)
	return ans

def checkPath(source, destination, g):
	visited = [0] * 101
	q = Q()
	q.append(source)
	visited[source] = 1
	while q:
		node = q.popleft()
		if node == destination:
			return 1
		for v in g[node]:
			if not visited[v]:
				q.append(v)
				visited[v] = 1
	return 0

def main():
	for _ in range(int(INPUT())):
		n = int(INPUT())
		q = list(map(int, INPUT().split()))
		remaining = sorted([*set([*range(1, n + 1)]) - set(q)], reverse=True)
		d = {}
		ans = [-1] * n
		for i in range(n):
			if q[i] not in d:
				ans[i] = q[i]
			d[q[i]] = 1
		for i in range(n):
			if ans[i] == -1:
				ans[i] = remaining.pop()
		valid = [ans[0]]
		for i in range(1, n):
			valid.append(max(ans[i], valid[i - 1]))
		if q == valid:
			for v in ans:
				PRINT('%d ' % v)
			PRINT('\n')
		else:
			PRINT('%d\n' % -1)
main()


from __future__ import print_function
from collections import *
from sys import stdin
import sys
from heapq import *
from math import log2, ceil, sqrt, gcd, log
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n,) = gil()
	a = gil()
	ans = [None] * n
	left = set(range(1, n + 1))
	left.remove(a[0])
	ans[0] = a[0]
	for i in range(1, n):
		if a[i] != a[i - 1]:
			ans[i] = a[i]
			if ans[i] in left:
				left.remove(ans[i])
	left = list(left)
	left.sort(reverse=True)
	for i in range(n):
		if ans[i] == None:
			if left:
				ans[i] = left.pop()
	if None in ans:
		print(-1)
	else:
		maxi = 0
		for i in range(n):
			maxi = max(maxi, ans[i])
			if a[i] != maxi:
				break
		if a[i] == maxi:
			print(*ans)
		else:
			print(-1)


for w in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	l = [0] * n
	count = [0] * (n + 1)
	c = 0
	t = 0
	if n == 1:
		if q[0] == 1:
			print(1)
		else:
			print(-1)
	else:
		l[0] = q[0]
		count[q[0]] = 1
		for i in range(1, n):
			if q[i] != q[i - 1]:
				l[i] = q[i]
				count[q[i]] = 1
				if i == 1:
					for j in range(max(t, 1), n + 1):
						if count[j] == 0:
							t = j
							break
				elif l[i] == t:
					for j in range(max(t, 1), n + 1):
						if j != 0 and count[j] == 0:
							t = j
							break
			elif t < q[i]:
				if t > 0 and count[t] == 0:
					count[t] = 1
					l[i] = t
					for j in range(max(t, 1), q[i]):
						if count[j] == 0:
							t = j
							break
				else:
					t1 = t
					for j in range(max(t, 1), q[i]):
						if count[j] == 0:
							t = j
							break
					if t != t1:
						count[t] = 1
						l[i] = t
					else:
						c = 1
						break
			else:
				c = 1
				break
		if c == 1:
			print(-1)
		else:
			for i in range(n):
				print(l[i], end=' ')
			print()


for _ in range(int(input())):
	try:
		n = int(input())
		q = list(map(int, input().split()))
		s = set(q)
		p = [q[0]] * n
		cnt = 1
		for i in range(1, n):
			if q[i - 1] < q[i]:
				p[i] = q[i]
			else:
				while cnt < q[i] and cnt in s:
					cnt += 1
				if cnt == q[i]:
					raise
				p[i] = cnt
				cnt += 1
		print(*p)
	except:
		print(-1)


t = int(input())
for test_i in range(t):
	n = int(input())
	arr = list(map(lambda el: int(el) - 1, input().split()))
	vis = [False for i in range(n)]
	cur_i = -1
	cur_el = arr[0]
	vis[arr[0]] = True
	ans = [arr[0]]
	have_ans = True
	for i in range(1, n):
		el = arr[i]
		if el != cur_el:
			ans.append(el)
			cur_el = el
			vis[el] = True
		else:
			while cur_i < cur_el:
				cur_i += 1
				if vis[cur_i] == False:
					ans.append(cur_i)
					vis[cur_i] = True
					break
			if cur_i == cur_el:
				have_ans = False
				break
	if have_ans:
		print(*[el + 1 for el in ans])
	else:
		print(-1)
	print()


t = int(input())
for i in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	p = [0] * n
	p[0] = q[0]
	y = 1
	r = 1
	s = set()
	s.add(p[0])
	for j in range(1, n):
		if q[j] < j + 1:
			print(-1)
			y = 0
			break
		if q[j] > q[j - 1]:
			p[j] = q[j]
		else:
			while True:
				if r in s:
					r += 1
				else:
					s.add(r)
					p[j] = r
					r += 1
					break
		s.add(p[j])
	if y == 1:
		for j in range(n):
			print(p[j], end=' ')
		print()


import sys as _sys

def main():
	t = int(input())
	for i_t in range(t):
		(n,) = _read_ints()
		q = tuple(_read_ints())
		try:
			result = find_p(q)
		except ValueError:
			print(-1)
		else:
			print(*result)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split())

def find_p(prefix_maximums):
	if not prefix_maximums:
		return []
	n = len(prefix_maximums)
	stairs_indices = [0]
	for i in range(1, n):
		if prefix_maximums[i] < prefix_maximums[i - 1]:
			raise ValueError
		if prefix_maximums[i] > prefix_maximums[i - 1]:
			stairs_indices.append(i)
	result = []
	is_number_used = [None] + [False] * n
	i_curr_number = 1
	for (i_i_curr_stair, i_curr_stair) in enumerate(stairs_indices):
		if i_i_curr_stair + 1 < len(stairs_indices):
			i_next_stair = stairs_indices[i_i_curr_stair + 1]
		else:
			i_next_stair = n
		stair_content = prefix_maximums[i_curr_stair]
		if is_number_used[stair_content]:
			raise ValueError
		result.append(stair_content)
		is_number_used[stair_content] = True
		for i_cell in range(i_curr_stair + 1, i_next_stair):
			while is_number_used[i_curr_number]:
				i_curr_number += 1
				if i_curr_number >= len(is_number_used):
					raise ValueError
			cell_content = i_curr_number
			if cell_content > stair_content:
				raise ValueError
			result.append(cell_content)
			is_number_used[cell_content] = True
	return result
main()


t = int(input())
for case_num in range(t):
	n = int(input())
	q = list(map(int, input().split(' ')))
	ans = []
	used = [False for i in range(n + 1)]
	current_max = 0
	current_min = 1
	ok = True
	for i in q:
		if i > current_max:
			ans.append(i)
			used[i] = True
			current_max = i
			while current_min <= n and used[current_min]:
				current_min += 1
		elif i == current_max:
			if current_min >= current_max:
				print(-1)
				ok = False
				break
			ans.append(current_min)
			used[current_min] = True
			while current_min <= n and used[current_min]:
				current_min += 1
		else:
			print(-1)
			ok = False
			break
	if ok:
		print(' '.join(map(str, ans)))


for t in range(int(input())):
	n = int(input())
	q = [0] + list(map(int, input().split()))
	p = [i for i in range(n + 1)]
	p[1] = q[1]
	nums = [True for i in range(n + 1)]
	nums[p[1]] = False
	left = 1
	right = p[1] - 1
	flag = True
	for i in range(2, n + 1):
		if q[i] != q[i - 1]:
			p[i] = q[i]
			right = p[i] - 1
			nums[p[i]] = False
		else:
			while not nums[left]:
				left += 1
			if left > right:
				flag = False
				break
			p[i] = left
			left += 1
	if flag:
		print(*p[1:])
	else:
		print(-1)


for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ar = l.copy()
	x = set()
	for i in range(1, n + 1):
		x.add(i)
	x.discard(ar[0])
	for i in range(1, n):
		if l[i] > l[i - 1]:
			x.discard(l[i])
		else:
			ar[i] = 0
	x2 = list(x)
	x2.sort()
	num = 0
	f = 0
	for j in range(n):
		if ar[j] == 0:
			ar[j] = x2[num]
			num += 1
		if ar[j] > l[j]:
			f = 1
	if f == 1:
		print('-1')
	else:
		print(*ar)


def solve(N, Q):
	used = set()
	(R, m, k) = ([], -1, 1)
	for q in Q:
		if q > m:
			R.append(q)
			used.add(q)
			m = q
			continue
		while k in used:
			k += 1
		if k > q:
			return None
		R.append(k)
		used.add(k)
		k += 1
	return R
T = int(input())
for _ in range(T):
	N = int(input())
	Q = list(map(int, input().split()))
	R = solve(N, Q)
	print(-1 if R is None else ' '.join(map(str, R)))


w = int(input())
for q in range(w):
	fr = 1
	n = int(input())
	a = list(map(int, input().split()))
	a.append(a[0] - 1)
	e = [1] * (n + 1)
	ei = 1
	r = [0] * n
	for i in range(n):
		if a[i] == a[i - 1]:
			while e[ei] == 0 and ei < n:
				ei += 1
			if ei > a[i]:
				print(-1)
				fr = 0
				break
			r[i] = ei
			e[ei] = 0
		elif e[a[i]] == 1:
			e[a[i]] = 0
			r[i] = a[i]
		else:
			print(-1)
			fr = 0
			break
	if fr:
		print(*r)


def read_line():
	return [int(x) for x in input().split()]

def read_int():
	return int(input())

def solve():
	n = read_int()
	a = read_line()
	pos = [0 for _ in range(n + 1)]
	b = [0 for _ in range(n + 1)]
	b[1] = a[0]
	pos[a[0]] = 1
	for i in range(n):
		if a[i] != a[i - 1]:
			b[i + 1] = a[i]
			pos[a[i]] = 1
	j = 1
	for i in range(1, n + 1):
		if b[i] == 0:
			while j <= n and pos[j] == 1:
				j += 1
			b[i] = j
			j += 1
	(max_el, flag) = (0, 0)
	for i in range(1, n + 1):
		max_el = max(max_el, b[i])
		if max_el != a[i - 1]:
			flag = 1
	if flag == 1:
		print(-1)
	else:
		for i in range(1, n + 1):
			print(b[i], end=' ')
		print()
t = read_int()
while t > 0:
	solve()
	t -= 1


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	ans = []
	ch = []
	for j in range(len(s)):
		if j == 0:
			if s[0] > 1:
				for o in range(1, s[0]):
					ch.append(o)
		elif s[j] - ans[-1] > 1:
			for o in range(ans[-1] + 1, s[j]):
				ch.append(o)
		ans.append(s[j])
	k = 0
	anss = 0
	an = []
	chh = True
	for j in range(len(ans)):
		if j > 0:
			if ans[j] <= j:
				chh = False
				print(-1)
				break
			if ans[j] == ans[j - 1]:
				anss += 1
				an.append(ch[k])
				k += 1
			else:
				an.append(ans[j])
			if ans[j] > s[j]:
				chh = False
				print(-1)
				break
		else:
			an.append(ans[j])
	if chh and anss == len(ch):
		print(*an)
	elif chh == True:
		print(-1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	av = set(range(1, n + 1))
	ans = []
	flag = 0
	for i in a:
		if i in av:
			ans.append(i)
			av.remove(i)
		else:
			for j in av:
				e = j
				break
			if e > i:
				flag = 1
				break
			else:
				ans.append(e)
				av.remove(e)
	if flag:
		print(-1)
	else:
		print(*ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	k = 1
	used = [False for _ in range(n + 2)]
	for i in range(n + 1):
		used[i] = False
	arr1 = []
	k = 1
	flag = 0
	for i in range(n):
		if used[arr[i]] == False:
			arr1.append(arr[i])
			used[arr[i]] = True
		elif used[k] == False:
			arr1.append(k)
			used[k] = True
			k += 1
		else:
			while used[k] != False:
				k += 1
			if k < arr[i]:
				arr1.append(k)
				used[k] = True
			else:
				flag = 1
	if flag == 1:
		print(-1)
	else:
		flag = 0
		for i in range(n):
			print(arr1[i], end=' ')
		print()


from collections import deque
import sys

def numbers_range(n):
	for i in range(n):
		yield 0
q = int(input())
for _ in range(q):
	n = int(input())
	data = list(numbers_range(n + 1))
	temp = []
	a = deque()
	for x in input().split():
		temp.append(int(x))
		data[int(x)] = 1
	for (i, x) in enumerate(data[1:]):
		if x == 0:
			a.append(i + 1)
	ans = [temp[0]]
	flg = False
	for i in range(len(temp) - 1):
		if temp[i] == temp[i + 1]:
			if len(a) > 0 and a[0] < temp[i]:
				ans.append(a.popleft())
			else:
				flg = True
				break
		else:
			ans.append(temp[i + 1])
	if flg:
		print(-1)
	else:
		print(*ans)


import sys
fin = sys.stdin
INF = 10 ** 9
tests = int(input())
for test in range(tests):
	n = int(input())
	max_list = list(map(int, fin.readline().split()))
	ans_list = list()
	cur_max = 0
	used = [False] * (n + 1)
	used_count = 0
	put = 1
	for i in range(n):
		maximum = max_list[i]
		if maximum > cur_max:
			ans_list.append(maximum)
			used[maximum] = True
			used_count += 1
			cur_max = maximum
			continue
		while put <= cur_max and used[put]:
			put += 1
		if put > cur_max:
			break
		ans_list.append(put)
		used[put] = True
		used_count += 1
	else:
		if used_count == n:
			for i in range(n):
				print(ans_list[i], end=' ')
			print()
			continue
	print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [False] * n
	b[a[0] - 1] = True
	k = 0
	res = [a[0]]
	flag = True
	for j in range(1, n):
		if a[j] == a[j - 1]:
			while k < n and b[k]:
				k += 1
			if k + 1 > a[j]:
				flag = False
				break
			res.append(k + 1)
			b[k] = True
		else:
			b[a[j] - 1] = True
			res.append(a[j])
	if flag:
		print(' '.join(map(str, res)))
	else:
		print(-1)


from math import *
import os, sys
from io import BytesIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	used = [0] * (n + 1)
	b[0] = a[0]
	used[a[0]] = 1
	f = True
	for i in range(1, n):
		if a[i] < i + 1:
			print(-1)
			f = False
			break
		if a[i] > a[i - 1]:
			b[i] = a[i]
			used[a[i]] = 1
	if not f:
		continue
	res = []
	for i in range(1, n + 1):
		if not used[i]:
			res.append(i)
	i = 0
	for c in b:
		if c == 0:
			print(res[i], end=' ')
			i += 1
		else:
			print(c, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	line = [int(i) for i in input().split()]
	check = set()
	maxy = 0
	answer = []
	for i in line:
		if i > maxy:
			for j in range(maxy + 1, i):
				check.add(j)
			answer.append(i)
		elif not check:
			print(-1)
			break
		else:
			x = check.pop()
			answer.append(x)
		maxy = max(i, maxy)
	else:
		print(*answer)


t = int(input())
for _ in range(t):
	n = int(input())
	q = [int(x) for x in input().split()]
	zapas = [x for x in range(1, q[0])]
	res = []
	res.append(q[0])
	for i in range(n - 1):
		if q[i] == q[i + 1]:
			if q[i + 1] > i + 1:
				res.append(zapas.pop())
			else:
				res = [-1]
				break
		else:
			zapas.extend([x for x in range(q[i] + 1, q[i + 1])])
			res.append(q[i + 1])
	print(*res)


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for tc in range(t):
	n = int(input())
	arr = [int(z) for z in input().split()]
	maxsofar = 0
	used = set()
	res = []
	ans = 0
	for i in range(n):
		if arr[i] > maxsofar:
			res.append(arr[i])
			for b in range(maxsofar + 1, arr[i]):
				used.add(b)
			maxsofar = max(maxsofar, arr[i])
		elif len(used) > 0:
			res.append(used.pop())
		else:
			ans = 1
			break
	if ans == 1:
		print(-1)
		continue
	print(' '.join([str(i) for i in res]))


t = int(input())
for q in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	ans = [0 for i in range(n)]
	used = [0 for i in range(n)]
	for i in range(n - 1):
		if p[i] != p[i + 1]:
			ans[i + 1] = p[i + 1]
			used[p[i + 1] - 1] = 1
	ans[0] = p[0]
	used[p[0] - 1] = 1
	nu = []
	for i in range(n):
		if not used[i]:
			nu.append(i)
	ptr = 0
	for j in range(n):
		if ans[j] == 0:
			ans[j] = nu[ptr] + 1
			ptr += 1
	pref = [ans[0]]
	for i in range(1, n):
		pref.append(max(pref[i - 1], ans[i]))
	if pref != p:
		print(-1)
	else:
		print(*ans)


from os import path
import sys
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, deque
from itertools import permutations
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(I()):
	n = I()
	ls = lint()
	(d, ans) = ({ls[0]: 1}, [0] * n)
	ans[0] = ls[0]
	(num, f) = (1, 0)
	for i in range(1, n):
		if ls[i - 1] != ls[i]:
			ans[i] = ls[i]
			d[ls[i]] = 1
		else:
			while num in d:
				num += 1
			if num >= ls[i]:
				f = 1
				break
			d[num] = 1
			ans[i] = num
	if f:
		print(-1)
	else:
		print(*ans)


t = int(input())
for magic in range(t):
	n = int(input())
	res = [0 for j in range(n + 1)]
	have = [1 for sth in range(n + 1)]
	br_p = 0
	given = [0] + list(map(int, input().split()))
	for i in range(1, n + 1):
		if given[i - 1] < given[i]:
			res[i] = given[i]
			have[given[i]] = 0
		elif given[i - 1] > given[i]:
			br_p = 1
			break
	if br_p:
		print(-1)
	else:
		ind_last = 1
		for i in range(1, n + 1):
			if res[i] == 0:
				while have[ind_last] == 0:
					ind_last += 1
				res[i] = ind_last
				ind_last += 1
		for i in range(1, n + 1):
			if given[i] < res[i]:
				br_p = 1
				break
		if br_p:
			print(-1)
		else:
			print(*res[1:])


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * (n + 2)
	c = 1
	d = a[0]
	ans = [a[0]]
	b[a[0]] = 1
	for i in range(1, len(a)):
		if a[i] == a[i - 1]:
			while b[c] != 0:
				c += 1
			if c > a[i]:
				ans = -1
				break
			else:
				b[c] = 1
				ans.append(c)
		else:
			ans.append(a[i])
			b[a[i]] = 1
	if ans == -1:
		print(ans)
	else:
		print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = set(a)
	s = sorted(list((i for i in range(1, 1 + n) if i not in l)))[::-1]
	ar = a.copy()
	ok = True
	for i in range(1, n):
		if a[i] == a[i - 1]:
			e = s.pop()
			if a[i] < e:
				ok = False
				break
			else:
				ar[i] = e
	if ok:
		print(*ar)
	else:
		print(-1)


for i in range(int(input())):
	n = int(input())
	used = [False for _ in range(n + 1)]
	q = list(map(int, input().split()))
	res = [-1 for _ in range(n)]
	mx = -float('INF')
	elem = 1
	for i in range(n):
		if q[i] > mx:
			mx = max(mx, q[i])
			used[q[i]] = True
			res[i] = q[i]
		else:
			while used[elem]:
				elem += 1
			used[elem] = True
			if q[i] > elem:
				res[i] = elem
			else:
				res = [-1]
				break
	print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	ans = [0] * n
	used = [False] * n
	ans[0] = A[0]
	used[A[0] - 1] = True
	if A[0] == 1:
		next = 2
	else:
		next = 1
	for i in range(1, n):
		if A[i] == A[i - 1]:
			if next > A[i]:
				print(-1)
				break
			ans[i] = next
			used[next - 1] = True
			next += 1
			while next < n + 1 and used[next - 1]:
				next += 1
		else:
			ans[i] = A[i]
			used[A[i] - 1] = True
			while next < n + 1 and used[next - 1]:
				next += 1
	else:
		for i in range(n):
			print(ans[i], end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().strip().split(' ')))
	l2 = []
	l3 = []
	f = 0
	lst.insert(0, 0)
	if n == 1:
		if lst[1] == 1:
			print(1)
		else:
			print(-1)
	else:
		for j in range(1, n + 1):
			if lst[j] != lst[j - 1]:
				l3.append(lst[j])
				if lst[j] - lst[j - 1] > 1:
					for k in range(lst[j - 1] + 1, lst[j]):
						l2.append(k)
			elif len(l2) == 0:
				print('-1')
				f = 1
				break
			elif l2[0] < lst[j]:
				l3.append(l2[0])
				del l2[0]
			else:
				print('-1')
				f = 1
				break
		if f == 0:
			for j in range(n):
				print(l3[j], end=' ')
			print()


cases = int(input())
for t in range(cases):
	n = int(input())
	q = list(map(int, input().split()))
	a = [0] * n
	prev = q[0]
	a[0] = prev
	p = []
	b = {i: True for i in range(1, n + 1)}
	b[prev] = False
	for i in range(1, n):
		if q[i] != prev:
			a[i] = q[i]
			b[q[i]] = False
		else:
			p.append(i)
		prev = q[i]
	b = [i for i in b if b[i]]
	c = 0
	f = 0
	for i in p:
		if a[i] == 0 and q[i] >= b[c]:
			a[i] = b[c]
			c += 1
		else:
			print(-1)
			f = 1
			break
	if f == 0:
		print(*a)


def solve():
	n = int(input())
	ar = list(map(int, input().split()))[:n]
	t = set(ar)
	c = [ar[0]]
	b = [i for i in range(1, n + 1) if i not in t]
	y = 0
	for i in range(1, n):
		if ar[i] != ar[i - 1]:
			c.append(ar[i])
		else:
			c.append(b[y])
			y = y + 1
	for i in range(n):
		if c[i] > ar[i]:
			print(-1)
			return
	print(*c)
for _ in range(int(input())):
	solve()


t = int(input())
ans = [0] * t
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = [0] * (n + 1)
	k = True
	for i in range(n):
		if a[i] <= i:
			k = False
			break
	if k and n > 2:
		s[0] = 1
		s[a[0]] = 1
		if n > 2:
			f = 1
		i = 1
		while i < n:
			if a[i] == a[i - 1]:
				s[a[i - 1]] = 1
				l = i
				while a[l] == a[i - 1] and l < n:
					while s[f] == 1:
						f += 1
					a[l] = f
					s[f] = 1
					l += 1
					if l == n:
						break
				i = l
			else:
				s[a[i]] = 1
				i += 1
		ans[j] = a
	elif k and n == 2:
		if a[0] == 1:
			ans[j] = [1, 2]
		else:
			ans[j] = [2, 1]
	elif k and n == 1:
		ans[j] = [1]
	else:
		ans[j] = [-1]
for i in range(t):
	print(' '.join(map(str, ans[i])))


for _ in range(int(input())):
	n = int(input())
	Q = list(map(int, input().split()))
	X = {Q[0]}
	(min_q, max_q) = (1, Q[0])
	for i in range(1, n):
		if Q[i] > max_q:
			max_q = Q[i]
			X.add(Q[i])
		else:
			for q in range(min_q, Q[i]):
				if q not in X:
					min_q = q + 1
					Q[i] = q
					X.add(q)
					break
			else:
				print(-1)
				break
	else:
		print(*Q)


t = int(input())
for request in range(t):
	n = int(input())
	(result, initial) = (list(map(int, input().split())), [])
	(box, flag) = ([], True)
	initial.append(result[0])
	for d in range(1, result[0]):
		box.append(d)
	for i in range(1, n):
		if result[i - 1] < result[i]:
			initial.append(result[i])
			for d in range(result[i - 1] + 1, result[i]):
				box.append(d)
		else:
			try:
				initial.append(box.pop())
			except:
				flag = False
				break
	if flag:
		print(*initial)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	res = True
	s = {}
	min = 1
	for i in range(1, n + 1):
		s[i] = 1
	b.append(a[0])
	s[a[0]] = 0
	if a[0] == min:
		min = 2
	for i in range(1, n):
		if a[i] > a[i - 1]:
			s[a[i]] = 0
			b.append(a[i])
			if a[i] == min:
				while min < n and (not s[min]):
					min += 1
		elif min > a[i]:
			res = False
			break
		else:
			b.append(min)
			s[min] = 0
			while min < n and (not s[min]):
				min += 1
	if res:
		print(*b)
	else:
		print(-1)
	print()


def box(n, m):
	m = [int(m[i]) for i in range(len(m))]
	g = []
	g.append(m[0])
	f = 0
	t = [i for i in range(1, m[0])]
	for i in range(1, len(m)):
		if m[i - 1] > m[i]:
			return -1
		if m[i - 1] < m[i]:
			t += [j for j in range(m[i - 1] + 1, m[i])]
			g.append(m[i])
		else:
			try:
				g.append(t[f])
			except:
				return -1
			f += 1
	return ' '.join([str(g[i]) for i in range(len(g))])
for i in range(int(input().strip())):
	print(box(int(input().strip()), input().strip().split()))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		d = {}
		d[a[0]] = 1
		ans = [0] * n
		ans[0] = a[0]
		t = 0
		for i in range(n):
			if a[i] < i + 1:
				wi(-1)
				t = 1
				break
		if t == 1:
			continue
		k = 0
		for i in range(1, n):
			if a[i] != a[i - 1]:
				if a[i] not in d:
					d[a[i]] = 1
				ans[i] = a[i]
		dict = OrderedDict(sorted(d.items()))
		need = []
		for i in range(1, n + 1):
			if i not in d:
				need.append(i)
		de = collections.deque(need)
		for i in range(n):
			if ans[i] == 0:
				ans[i] = de[0]
				de.popleft()
		print(*ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
for _i in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	B = [i for i in range(1, n + 1)]
	P = [0] * n
	last = 0
	cx = 0
	f = True
	for j in range(n):
		if q[j] > last:
			P[j] = q[j]
			B[q[j] - 1] = 0
			last = q[j]
		else:
			while B[cx] == 0:
				cx += 1
			if B[cx] < q[j]:
				P[j] = B[cx]
				B[cx] = 0
			else:
				print(-1)
				f = False
				break
	if f:
		for j in range(n):
			print(P[j], end=' ')
		print()


t = int(input())
for j in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	s = set((i + 1 for i in range(n)))
	s.difference_update(set(array))
	a = list(s)
	ans = list()
	x = 0
	h = 1
	prev = 0
	for elem in array:
		if prev != elem:
			ans.append(elem)
			prev = elem
		elif a[x] > elem:
			h = 0
			break
		else:
			ans.append(a[x])
			x += 1
	if h:
		print(*ans)
	else:
		print(-1)


t = int(input())
for g in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list((False for i in range(n)))
	flag = False
	count = 0
	res = list(range(n))
	for i in range(n):
		if i == 0:
			res[i] = a[i]
			b[a[i] - 1] = True
		elif a[i] != a[i - 1]:
			res[i] = a[i]
			b[a[i] - 1] = True
		else:
			for j in range(count, n):
				if j + 1 > a[i]:
					flag = True
					count = j
					break
				elif not b[j]:
					res[i] = j + 1
					b[j] = True
					count = j
					break
	if flag:
		print(-1)
	else:
		for i in range(n):
			print(res[i], end=' ')
		print()


def f():
	n = int(input())
	arr = list(map(int, input().split()))
	res = [0] * n
	res[0] = arr[0]
	may = set([i for i in range(1, n + 1)])
	may.remove(arr[0])
	for i in range(1, len(arr)):
		if arr[i] != arr[i - 1]:
			may.remove(arr[i])
			res[i] = arr[i]
		else:
			for k in may:
				if k < arr[i]:
					res[i] = k
					may.remove(k)
					break
			else:
				return -1
	return res
t = int(input())
for _ in range(t):
	x = f()
	if x == -1:
		print(-1)
	else:
		print(*x)


a = int(input())
for x in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	j = []
	t = 1
	s = {}
	ma = 0
	g = 0
	for y in range(b):
		if y == 0:
			s[c[y]] = 1
			j.append(c[y])
			ma = c[y]
		elif c[y] > ma:
			s[c[y]] = 1
			j.append(c[y])
			ma = c[y]
		else:
			l = 0
			while t < ma:
				if s.get(t) == None:
					s[t] = 1
					j.append(t)
					l = -1
					break
				else:
					t += 1
			if l != -1:
				g = -1
				break
	if g == -1:
		print(-1)
	else:
		print(*j)


t = int(input())
for tt in range(t):
	n = int(input())
	ent = list(map(int, input().split()))
	used = [0] * (n + 1)
	mnex = 1
	mx = 0
	ans = []
	ansex = True
	for i in range(n):
		if ent[i] > mx:
			mx = ent[i]
			if used[mx] == 0:
				ans.append(mx)
				used[mx] = 1
			else:
				ansex = False
				break
		else:
			while used[mnex] == 1:
				mnex += 1
			if mnex <= mx:
				used[mnex] = 1
				ans.append(mnex)
				mnex += 1
			else:
				ansex = False
				break
	if ansex:
		print(*ans)
	else:
		print(-1)


def solve():
	n = int(input())
	q = list(map(int, input().split()))
	s = set(q)
	p = [q[0]] * n
	cnt = 1
	for i in range(1, n):
		if q[i - 1] < q[i]:
			p[i] = q[i]
		else:
			while cnt < q[i] and cnt in s:
				cnt += 1
			if cnt == q[i]:
				print(-1)
				return
			p[i] = cnt
			cnt += 1
	print(*p)
for _ in range(int(input())):
	solve()


from collections import OrderedDict
for _ in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	tmp = OrderedDict()
	for i in range(1, n + 1):
		tmp[i] = True
	visited = [False] * (n + 1)
	ans = []
	flag = True
	for i in range(n):
		if q[i] < next(iter(tmp)):
			flag = False
			print(-1)
			break
		if visited[q[i]] == False:
			visited[q[i]] = True
			ans.append(q[i])
			tmp.pop(q[i])
		elif visited[q[i]] == True:
			k = next(iter(tmp))
			ans.append(k)
			visited[k] = True
			tmp.pop(k)
	if flag:
		print(*ans)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	arr = [s[0]]
	d = {s[0]: 1}
	pr = 1
	j = 1
	for i in range(1, n):
		if s[i] > s[i - 1]:
			arr.append(s[i])
			d[s[i]] = 1
		else:
			p = 0
			while j < s[i]:
				if j not in d:
					d[j] = 1
					arr.append(j)
					p = 1
					break
				j += 1
			if p == 0:
				print(-1)
				pr = 0
				break
	if pr:
		print(*arr)


for _ in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	p = [0] * n
	sp = 1
	p[0] = q[0]
	if n not in q:
		print(-1)
		continue
	if q[0] > n:
		print(-1)
		continue
	if q[0] == 1:
		sp += 1
	ok = False
	s = set()
	s.add(q[0])
	for i in range(1, n):
		if q[i] > n:
			print(-1)
			ok = True
			break
		if q[i] > q[i - 1]:
			if q[i] in s:
				print(-1)
				ok = True
				break
			p[i] = q[i]
			s.add(p[i])
		elif q[i] < q[i - 1]:
			print(-1)
			ok = True
			break
		else:
			while sp in s:
				sp += 1
			if sp > q[i]:
				print(-1)
				ok = True
				break
			p[i] = sp
			s.add(p[i])
			sp += 1
	if ok:
		continue
	print(' '.join(map(str, p)))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(ii) for ii in input().split()]
	b = [0 for ii in range(n)]
	was = [0 for ii in range(n + 1)]
	minimum = 1
	for j in range(n):
		if j == 0 or a[j] != a[j - 1]:
			was[a[j]] = 1
			b[j] = a[j]
		else:
			while was[minimum] == 1:
				minimum += 1
			if minimum > a[j]:
				minimum = -1
				break
			b[j] = minimum
			was[minimum] = 1
	if minimum == -1:
		print(-1)
	else:
		for j in b:
			print(j, end=' ')
		print('')


t = int(input())
a = []
for _ in range(t):
	n = int(input())
	a.append(list(map(int, input().split())))
for q in a:
	ans = [q[0]]
	indxs = []
	for i in range(1, len(q)):
		if q[i] > q[i - 1]:
			ans.append(q[i])
		else:
			ans.append(None)
			indxs.append(i)
	if None not in ans:
		print(' '.join([str(e) for e in ans]))
	else:
		s = list(set(range(1, len(q) + 1)) - set(ans))
		for indx in enumerate(list(indxs)):
			ans[indx[1]] = s[indx[0]]
			if s[indx[0]] >= q[indx[1]]:
				print(-1)
				break
		else:
			print(' '.join([str(e) for e in ans]))


def main():
	t = int(input())
	for __ in range(t):
		n = int(input())
		already_present = [False] * n
		q = list(map(int, input().split()))
		m = 0
		p = []
		not_perm = False
		avail = 0
		for i in q:
			if already_present[i - 1]:
				while avail < n:
					if avail >= i:
						not_perm = True
						break
					if not already_present[avail]:
						p.append(avail + 1)
						already_present[avail] = True
						break
					avail += 1
			else:
				p.append(i)
				already_present[i - 1] = True
			if not_perm:
				break
		if not_perm:
			print(-1)
		else:
			print(*p)
main()


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	N = [0 for j in range(1, n + 1)]
	N1 = [j for j in range(1, n + 1)]
	last = 0
	for j in range(n):
		if last != a[j]:
			last = a[j]
			N[j] = a[j]
			N1[a[j] - 1] = 0
	j1 = 0
	for j in range(n):
		if N[j] == 0:
			if N1[j1] == 0:
				while N1[j1] == 0:
					j1 += 1
			N[j] = N1[j1]
			if N[j] > a[j]:
				N = [-1]
				break
			N1[j1] = 0
	ans.append(N)
for i in ans:
	print(*i)


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	q = [int(x) for x in input().split()]
	p = [0 for _ in range(n)]
	isTaken = [False for _ in range(n + 1)]
	j = 1
	prevMax = 0
	ok = True
	for i in range(n):
		x = q[i]
		if x > prevMax:
			prevMax = x
			isTaken[x] = True
			p[i] = x
		else:
			if x < prevMax:
				ok = False
				break
			while isTaken[j]:
				j += 1
			if j > prevMax:
				ok = False
				break
			p[i] = j
			isTaken[j] = True
	if ok:
		print(' '.join([str(x) for x in p]))
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	ans = [0 for i in range(n)]
	a = list(map(int, input().split()))
	if a[-1] != n:
		print(-1)
	else:
		prtnt = False
		cur = n + 1
		pos = -1
		posval = 0
		used = set()
		counter = 1
		counterlim = a[0]
		for i in range(len(a)):
			(cur, prev) = (a[i], cur)
			if cur != prev:
				ans[i] = cur
				if counter - 1 > cur:
					prtnt = True
				counterlim = cur
				used.add(cur)
			else:
				while counter in used:
					counter += 1
				ans[i] = counter
				if counter > counterlim:
					prtnt = True
				counter += 1
		if not prtnt:
			print(' '.join(map(str, ans)))
		else:
			print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	m = []
	d = 0
	m.append(0)
	for j in range(n):
		m.append(m[j] + 1)
	spi = list(map(int, input().split()))
	max = 1
	for j in range(n):
		if spi[j] > max:
			s = m[j + 1]
			m[j + 1] = spi[j]
			max = spi[j]
			m[spi[j]] = s
		if max < j + 1:
			d = 1
			break
	if d == 1:
		print(-1)
	else:
		for j in range(n):
			print(m[j + 1], end=' ')
		print(' ')


t = int(input())
for i in range(t):
	n = int(input())
	u = [0] * (n + 1)
	u[0] = 1
	inp = list(map(int, input().split()))
	ans = []
	m = 0
	last = 0
	f = True
	for j in range(n):
		if inp[j] > m:
			if u[inp[j]] == 1:
				f = False
				break
			else:
				u[inp[j]] = 1
				ans.append(inp[j])
				m = inp[j]
		else:
			while last <= n and u[last] == 1:
				last += 1
			if last == n:
				f = False
				break
			elif last < m:
				ans.append(last)
				u[last] = 1
			else:
				f = False
				break
	if not f:
		print(-1)
	else:
		for k in range(n):
			print(ans[k], end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	q = [int(x) for x in input().split()]
	an = [-1] * n
	an[0] = q[0]
	x = [False] * (n + 1)
	x[q[0]] = True
	for j in range(1, n):
		if q[j] != q[j - 1]:
			an[j] = q[j]
			x[q[j]] = True
	j = 1
	qa = True
	for i in range(n):
		if an[i] == -1:
			if x[j] == False:
				an[i] = j
			else:
				while x[j] == True and j < n + 1:
					j += 1
				an[i] = j
			if an[i] > p:
				qa = False
				break
			x[j] = True
			j += 1
		else:
			p = an[i]
		if j == n + 1:
			break
	if sorted(q) != q or -1 in an:
		print(-1)
	elif not qa:
		print(-1)
	else:
		print(*an)


def read():
	n = int(input())
	q = list(map(int, input().split()))
	return (n, q)

def solve(n, q):
	marked = [False] * (n + 1)
	a = [0] * n
	c = 1
	a[0] = q[0]
	marked[a[0]] = True
	for i in range(1, n):
		if q[i] > q[i - 1]:
			a[i] = q[i]
			marked[a[i]] = True
		else:
			while marked[c]:
				c += 1
			if c > q[i]:
				return None
			a[i] = c
			marked[c] = True
	return a
for t in range(int(input())):
	result = solve(*read())
	if result:
		print(*result)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	x = set()
	res = []
	mn = 1
	fl = True
	for k in range(len(s)):
		if k == 0:
			res.append(s[k])
			x.add(s[k])
		elif s[k - 1] > s[k]:
			print(-1)
			fl = False
			break
		elif s[k] > s[k - 1]:
			res.append(s[k])
			x.add(s[k])
		else:
			while mn in x:
				mn += 1
			if mn > s[k]:
				print(-1)
				fl = False
				break
			else:
				res.append(mn)
				mn += 1
	if fl:
		print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	pr = [0] * n
	ans = [0] * n
	ans[0] = q[0]
	sh = 0
	s = set([q[0]])
	for i in range(1, n):
		if q[i] == q[i - 1]:
			pr[i] = pr[i - 1]
			sh += 1
		else:
			pr[i] = i
			ans[i] = q[i]
			s.add(q[i])
	steak = []
	for i in range(n, 0, -1):
		if i not in s:
			steak.append(i)
	tr = True
	for i in range(n):
		if ans[i] == 0:
			x = steak.pop()
			if x < q[pr[i]]:
				ans[i] = x
			else:
				tr = False
				break
	if tr:
		print(*ans)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	flag = [0] * (n + 1)
	qs = list(map(int, input().split()))
	j = 1
	ans = [0] * n
	f = True
	mx = -1
	for (i, q) in enumerate(qs):
		if flag[q] == 0:
			ans[i] = q
			flag[q] = 1
			mx = q
		else:
			while flag[j] == 1:
				j += 1
			if j > mx:
				f = False
				break
			ans[i] = j
			flag[j] = 1
	if not f:
		print(-1)
	else:
		print(*ans)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
from math import inf, log, ceil
for _ in range(t()):
	n = t()
	a = list(ll())
	p = [a[0]]
	se = sorted(set(range(1, n + 1)).difference(set(a)))
	i = 1
	while i < n:
		if a[i] > p[i - 1]:
			p.append(a[i])
			i += 1
		elif a[i] == p[i - 1]:
			j = i
			while j < n and a[j] == p[i - 1]:
				p.append(se.pop(0))
				j += 1
			i = j
		else:
			p.append(p[i - 1])
			i += 1
	dp = [a[0]]
	if len(se) == 0:
		for i in range(1, n):
			dp.append(max(dp[i - 1], p[i]))
	if dp == a and len(se) == 0:
		print(*p)
	else:
		print(-1)


t = int(input())
for zz in range(t):
	n = int(input())
	q = [int(i) for i in input().split()]
	p = [-1] * n
	p[0] = q[0]
	a = set()
	for i in range(n):
		a.add(i + 1)
	a.remove(q[0])
	ad = 0
	for i in range(1, n):
		if q[i - 1] != q[i]:
			p[i] = q[i]
			a.remove(q[i])
			ad += 1
	a = list(a)
	a.sort()
	left = n - ad
	i = 0
	j = 0
	imp = False
	while i < n:
		if p[i] == -1:
			if a[j] >= q[i] or left <= 0:
				imp = True
				break
			p[i] = a[j]
			j += 1
			left -= 1
		i += 1
	if imp:
		print(-1)
	else:
		print(' '.join(map(str, p)))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	used = [0 for i in range(n + 2)]
	ans = []
	minimum = 1
	ans.append(a[0])
	used[a[0]] = 1
	if a[0] == 1:
		minimum = 2
	for i in range(1, len(a)):
		if a[i] != a[i - 1]:
			ans.append(a[i])
			used[a[i]] = 1
			if a[i] == minimum:
				minimum += 1
		else:
			ans.append(minimum)
			used[minimum] = 1
			while used[minimum] == 1:
				minimum += 1
	maximum = 0
	flag = True
	for i in range(len(ans)):
		maximum = max(maximum, ans[i])
		if a[i] != maximum:
			flag = False
	if flag and a[-1] == n:
		print(' '.join(map(str, ans)))
	else:
		print(-1)