Monocarp and Polycarp are learning new programming techniques. Now they decided to try pair programming.

It's known that they have worked together on the same file for $n + m$ minutes. Every minute exactly one of them made one change to the file. Before they started, there were already $k$ lines written in the file.

Every minute exactly one of them does one of two actions: adds a new line to the end of the file or changes one of its lines.

Monocarp worked in total for $n$ minutes and performed the sequence of actions $[a_1, a_2, \dots, a_n]$. If $a_i = 0$, then he adds a new line to the end of the file. If $a_i > 0$, then he changes the line with the number $a_i$. Monocarp performed actions strictly in this order: $a_1$, then $a_2$, ..., $a_n$.

Polycarp worked in total for $m$ minutes and performed the sequence of actions $[b_1, b_2, \dots, b_m]$. If $b_j = 0$, then he adds a new line to the end of the file. If $b_j > 0$, then he changes the line with the number $b_j$. Polycarp performed actions strictly in this order: $b_1$, then $b_2$, ..., $b_m$.

Restore their common sequence of actions of length $n + m$ such that all actions would be correct — there should be no changes to lines that do not yet exist. Keep in mind that in the common sequence Monocarp's actions should form the subsequence $[a_1, a_2, \dots, a_n]$ and Polycarp's — subsequence $[b_1, b_2, \dots, b_m]$. They can replace each other at the computer any number of times.

Let's look at an example. Suppose $k = 3$. Monocarp first changed the line with the number $2$ and then added a new line (thus, $n = 2, \: a = [2, 0]$). Polycarp first added a new line and then changed the line with the number $5$ (thus, $m = 2, \: b = [0, 5]$).

Since the initial length of the file was $3$, in order for Polycarp to change line number $5$ two new lines must be added beforehand. Examples of correct sequences of changes, in this case, would be $[0, 2, 0, 5]$ and $[2, 0, 0, 5]$. Changes $[0, 0, 5, 2]$ (wrong order of actions) and $[0, 5, 2, 0]$ (line $5$ cannot be edited yet) are not correct.


-----Input-----

The first line contains an integer $t$ ($1 \le t \le 1000$). Then $t$ test cases follow. Before each test case, there is an empty line.

Each test case contains three lines. The first line contains three integers $k$, $n$, $m$ ($0 \le k \le 100$, $1 \le n, m \le 100$) — the initial number of lines in file and lengths of Monocarp's and Polycarp's sequences of changes respectively.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 300$).

The third line contains $m$ integers $b_1, b_2, \dots, b_m$ ($0 \le b_j \le 300$).


-----Output-----

For each test case print any correct common sequence of Monocarp's and Polycarp's actions of length $n + m$ or -1 if such sequence doesn't exist.


-----Examples-----

Input
5

3 2 2
2 0
0 5

4 3 2
2 0 5
0 6

0 2 2
1 0
2 3

5 4 4
6 0 8 0
0 7 0 9

5 4 1
8 7 8 0
0
Output
2 0 0 5 
0 2 0 6 5 
-1
0 6 0 7 0 8 0 9
-1


-----Note-----

None

Difficulty: EASY
Tags: Amortized analysis

Greedy algorithms
Skill types: Amortized analysis

Greedy algorithms

Starter code:

Solutions:
def fun3(k):
	flag = False
	while h:
		x = h.pop(0)
		if x == 0:
			k += 1
			re.append(x)
		elif x <= k:
			re.append(x)
		else:
			flag = True
			break
	return flag

def fun2(k):
	flag = False
	while j:
		x = j.pop(0)
		if x == 0:
			k += 1
			re.append(x)
		elif x <= k:
			re.append(x)
		else:
			flag = True
			break
	return flag
t = int(input())
while t:
	tem = input()
	t -= 1
	(k, n, m) = map(int, input().split())
	j = list(map(int, input().split()))
	h = list(map(int, input().split()))
	re = []
	flag = False
	while j and h:
		x = min(j[0], h[0])
		if j[0] <= h[0]:
			j.pop(0)
		else:
			h.pop(0)
		if x == 0:
			k += 1
			re.append(x)
		elif x <= k:
			re.append(x)
		else:
			flag = True
			break
	if flag:
		print(-1)
	else:
		flag = fun2(k)
		if flag:
			print(-1)
		else:
			flag = fun3(k)
			if flag:
				print(-1)
			else:
				print(*re)


for _ in range(int(input())):
	weojov = input()
	klist = [int(x) for x in input().split()]
	k = klist[0]
	n = klist[1]
	m = klist[2]
	a = 0
	b = 0
	mono = [int(x) for x in input().split()]
	poly = [int(x) for x in input().split()]
	ans = []
	for i in range(m + n):
		if a < n:
			if mono[a] <= k:
				if mono[a] == 0:
					k += 1
				ans.append(str(mono[a]))
				a += 1
				continue
			elif b < m:
				if poly[b] <= k:
					if poly[b] == 0:
						k += 1
					ans.append(str(poly[b]))
					b += 1
					continue
				else:
					ans = ['-1']
					break
			else:
				ans = ['-1']
				break
		elif b < m:
			if poly[b] <= k:
				if poly[b] == 0:
					k += 1
				ans.append(str(poly[b]))
				b += 1
				continue
			else:
				ans = ['-1']
				break
		else:
			ans = ['-1']
			break
	print(' '.join(ans))


t = int(input())
for i in range(t):
	s = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = 0
	q = 0
	l = []
	f = 1
	while True:
		if p < n and a[p] <= k:
			if a[p] == 0:
				k = k + 1
			l.append(a[p])
			p = p + 1
		elif q < m and b[q] <= k:
			if b[q] == 0:
				k = k + 1
			l.append(b[q])
			q = q + 1
		else:
			break
	if p < n or q < m:
		print(-1)
	else:
		print(*l, end=' ')
	print()


def solve():
	D = input()
	(K, N, M) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ans = []
	i = 0
	j = 0
	while i < N or j < M:
		if i == N:
			if B[j] == 0:
				ans.append(B[j])
				j += 1
				K += 1
			elif B[j] <= K:
				ans.append(B[j])
				j += 1
			else:
				return -1
		elif j == M:
			if A[i] == 0:
				ans.append(A[i])
				i += 1
				K += 1
			elif A[i] <= K:
				ans.append(A[i])
				i += 1
			else:
				return -1
		elif A[i] == 0:
			ans.append(A[i])
			i += 1
			K += 1
		elif B[j] == 0:
			ans.append(B[j])
			j += 1
			K += 1
		elif A[i] <= K:
			ans.append(A[i])
			i += 1
		elif B[j] <= K:
			ans.append(B[j])
			j += 1
		else:
			return -1
	return ans
T = int(input())
for _ in range(T):
	x = solve()
	if x == -1:
		print(x)
	else:
		print(*x)


def pairProgramming(k, n, m, a, b):
	i = 0
	j = 0
	l = []
	while i < n or j < m:
		while i < n and (k >= a[i] or a[i] == 0):
			l.append(a[i])
			if a[i] == 0:
				k += 1
			i += 1
		if j < m and k < b[j]:
			print('-1')
			return
		while j < m and (k >= b[j] or b[j] == 0):
			l.append(b[j])
			if b[j] == 0:
				k += 1
			j += 1
		if i < n and k < a[i]:
			print('-1')
			return
	print(*l)
for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pairProgramming(k, n, m, a, b)


t = int(input())
for i in range(0, t):
	emptyLine = input()
	(k, n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	i = 0
	j = 0
	result = []
	while i < n and j < m:
		if A[i] < B[j]:
			result.append(A[i])
			i += 1
		else:
			result.append(B[j])
			j += 1
	while i < n:
		result.append(A[i])
		i += 1
	while j < m:
		result.append(B[j])
		j += 1
	count = k
	result1 = 0
	for i in result:
		if i == 0:
			count += 1
		elif i > count:
			result1 = -1
	if result1 == 0:
		result = [str(item) for item in result]
		print(' '.join(result))
	else:
		print(-1)


def solve(k, A, B):
	n = len(A)
	m = len(B)
	(i, j) = (0, 0)
	res = []
	for _ in range(n + m):
		if i < n and (A[i] == 0 or A[i] <= k):
			if A[i] == 0:
				k += 1
			res.append(A[i])
			i += 1
		elif j < m and (B[j] == 0 or B[j] <= k):
			if B[j] == 0:
				k += 1
			res.append(B[j])
			j += 1
		else:
			return [-1]
	return res
t = int(input())
for _ in range(t):
	_ = input()
	(k, n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	print(' '.join((str(x) for x in solve(k, A, B))))


from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

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 = read(self._fd, max(fstat(self._fd).st_size, 8192))
			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 = read(self._fd, max(fstat(self._fd).st_size, 8192))
			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:
			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')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

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

def isInt(s):
	return '0' <= s[0] <= '9'

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

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

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def lcm(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
num = getInt()
for _ in range(num):
	getStr()
	(k, n, m) = zzz()
	name1 = zzz()
	name2 = zzz()
	ans = []
	left1 = 0
	left2 = 0
	for i in range(n + m):
		(x, y) = (float('inf'), float('inf'))
		if left1 < n:
			x = name1[left1]
		if left2 < m:
			y = name2[left2]
		if y > x:
			ans.append(x)
			left1 += 1
		else:
			ans.append(y)
			left2 += 1
	ok = 1
	bad = 0
	for i in ans:
		if i == 0:
			bad += 1
		elif bad + k < i:
			ok = 0
	print(*(ans if ok else [-1]))


import math
modulo = 10 ** 9 + 7
n_tests = int(input())
for test in range(n_tests):
	input()
	(k, n, m) = list(map(int, input().split()))
	a = list(input().split(' '))
	b = list(input().split(' '))
	a = [int(x) for x in a]
	b = [int(x) for x in b]
	res = ''
	fail = False
	while len(a) != 0 or len(b) != 0:
		if len(b) == 0 or (not len(a) == 0 and a[0] < b[0]):
			if a[0] > k:
				fail = True
				break
			if a[0] == 0:
				k += 1
			res += str(a[0]) + ' '
			a.pop(0)
		else:
			if b[0] > k:
				fail = True
				break
			if b[0] == 0:
				k += 1
			res += str(b[0]) + ' '
			b.pop(0)
	if not fail:
		print(res)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	s = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	ans = 1
	i = 0
	j = 0
	while i < len(a) and j < len(b):
		if a[i] == 0:
			k += 1
			i += 1
			c.append(0)
		elif b[j] == 0:
			k += 1
			j += 1
			c.append(0)
		else:
			min_ = b[j]
			j += 1
			if a[i] < min_:
				min_ = a[i]
				j -= 1
				i += 1
			if min_ <= k:
				c.append(min_)
			else:
				ans = 0
				break
	while j != len(b):
		c.append(b[j])
		if b[j] == 0:
			k += 1
		elif b[j] > k:
			ans = 0
		j += 1
	while i != len(a):
		c.append(a[i])
		if a[i] == 0:
			k += 1
		elif a[i] > k:
			ans = 0
		i += 1
	if ans:
		print(*c)
	else:
		print(-1)


t = int(input())

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

def do_step(arr, i, k, order):
	order.append(arr[i])
	if arr[i] == 0:
		return (True, i + 1, k + 1)
	if arr[i] <= k:
		return (True, i + 1, k)
	else:
		return (False, -1, -1)

def get_order(k, a, b):
	(n, m) = (len(a), len(b))
	order = []
	(i, j) = (0, 0)
	while i != n or j != m:
		if i == n or (j != m and a[i] > b[j]):
			(ok, j, k) = do_step(b, j, k, order)
		else:
			(ok, i, k) = do_step(a, i, k, order)
		if not ok:
			return [-1]
	return order
for _ in range(t):
	input()
	(k, _, _) = read_ints()
	(a, b) = (read_ints(), read_ints())
	print(' '.join(map(str, get_order(k, a, b))))


t = int(input())
for aaaaaaaaa in range(t):
	enter = input()
	y = []
	knm = [int(i) for i in input().split()]
	n = [int(i) for i in input().split()]
	m = [int(i) for i in input().split()]
	k = knm[0]
	n.append(301)
	m.append(301)
	l = 0
	for i in range(knm[1] + knm[2]):
		if n[0] == 0:
			y.append(0)
			k += 1
			del n[0]
		elif m[0] == 0:
			y.append(0)
			k += 1
			del m[0]
		elif k >= n[0]:
			y.append(n[0])
			del n[0]
		elif k >= m[0]:
			y.append(m[0])
			del m[0]
		elif n[0] == 301:
			enter = ''
		elif m[0] == 301:
			enter = ''
		else:
			print(-1)
			l = 1
			break
	if knm[1] + knm[2] > len(y) and l == 0:
		print(-1)
	elif l == 0:
		for i in range(len(y)):
			enter += str(y[i]) + ' '
		print(enter)


import sys
N = int(200000.0 + 5)
sys.setrecursionlimit(N)

def charming():
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = list()
	p = 0
	for i in a:
		if i == 0:
			k += 1
		elif i > k:
			while p < len(b):
				if b[p] == 0:
					p += 1
					k += 1
					res.append(b[p - 1])
				elif b[p] <= k:
					p += 1
					res.append(b[p - 1])
				else:
					break
			if i > k:
				print('-1')
				return
		res.append(i)
	for i in b[p:len(b)]:
		if i == 0:
			k += 1
		elif i > k:
			print('-1')
			return
		res.append(i)
	for i in res:
		print(i, end=' ')
	print()
for t in range(int(input())):
	charming()


t = int(input())
for i in range(0, t):
	c = input()
	(k, n, m) = map(int, input().split())
	lsta = list(map(int, input().split()))
	lstb = list(map(int, input().split()))
	a = 0
	b = 0
	out = []
	g = 0
	while a < n or b < m:
		tempa = a
		tempb = b
		if a < n and lsta[a] <= k:
			if lsta[a] == 0:
				k += 1
			out.append(lsta[a])
			a += 1
		elif b < m and lstb[b] <= k:
			if lstb[b] == 0:
				k += 1
			out.append(lstb[b])
			b += 1
		if a == tempa and b == tempb:
			g = 1
			print(-1)
			break
	if g == 0:
		print(*out, end=' ')
		print()


def solve(a, b):
	ans = []
	totallen = k
	for i in range(n + m):
		if a:
			if a[0] == 0:
				totallen += 1
				ans.append(a.pop(0))
				continue
			elif a[0] <= totallen:
				ans.append(a.pop(0))
				continue
		if b:
			if b[0] == 0:
				totallen += 1
				ans.append(b.pop(0))
				continue
			elif b[0] <= totallen:
				ans.append(b.pop(0))
				continue
		return [-1]
	return ans
for t in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(*solve(a, b))


for input_number in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	j = 0
	s = ''
	while not (i == n and j == m):
		if i == n or a[i] != 0:
			if i != n and a[i] <= k:
				s += str(a[i]) + ' '
				i += 1
			else:
				if j == m or b[j] > k:
					print(-1)
					break
				if b[j] == 0:
					k += 1
				s += str(b[j]) + ' '
				j += 1
		else:
			s += str(a[i]) + ' '
			i += 1
			k += 1
	else:
		print(s)


from sys import stdin, stdout, setrecursionlimit
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
import heapq
for _ in range(it()):
	input()
	(k, n, m) = mp()
	(a, b) = (mp(), mp())
	(a, b) = (deque(a), deque(b))
	v = []
	flag = 0
	while a and b:
		if a[0] == 0:
			a.popleft()
			v.append(0)
			k += 1
		elif b[0] == 0:
			b.popleft()
			v.append(0)
			k += 1
		elif a[0] < b[0]:
			if k < a[0]:
				flag = 1
				print(-1)
				break
			else:
				v.append(a[0])
				a.popleft()
		elif k < b[0]:
			flag = 1
			print(-1)
			break
		else:
			v.append(b[0])
			b.popleft()
	if flag:
		pass
	else:
		while a:
			if a[0] == 0:
				a.popleft()
				v.append(0)
				k += 1
			elif k < a[0]:
				flag = 1
				print(-1)
				break
			else:
				v.append(a[0])
				a.popleft()
		while b:
			if b[0] == 0:
				b.popleft()
				v.append(0)
				k += 1
			elif k < b[0]:
				flag = 1
				print(-1)
				break
			else:
				v.append(b[0])
				b.popleft()
		if not flag:
			print(*v)


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


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
inf = 10 ** 20
mod = 10 ** 9 + 7

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

def II():
	return int(input())

def LS():
	return list(input().split())

def S():
	return input()

def solve():
	(k, n, m) = LI()
	a_list = collections.deque(LI())
	b_list = collections.deque(LI())
	ans = list()
	while a_list or b_list:
		a = b = inf
		if a_list:
			a = a_list.popleft()
		if b_list:
			b = b_list.popleft()
		if a == 0 or a <= k:
			ans.append(a)
			if b < inf:
				b_list.appendleft(b)
			if a == 0:
				k += 1
			continue
		if b == 0 or b <= k:
			ans.append(b)
			if a < inf:
				a_list.appendleft(a)
			if b == 0:
				k += 1
			continue
		return [-1]
	return ans

def main():
	t = II()
	res = list()
	for _ in range(t):
		_ = S()
		res.append(solve())
	for ans in res:
		print(*ans)
	return 0
main()


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

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter, defaultdict
import math
import heapq
for _ in range(int(input())):
	s = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	j = 0
	f = 0
	ls = [-1] * (n + m)
	for y in range(n + m):
		if i < n and a[i] <= k:
			if a[i] == 0:
				k += 1
			ls[y] = a[i]
			i += 1
		elif j < m and b[j] <= k:
			if b[j] == 0:
				k += 1
			ls[y] = b[j]
			j += 1
		else:
			f = 1
			break
	if f == 1:
		print(-1)
	else:
		print(*ls)


t = int(input())
for _ in range(t):
	_ = input()
	(k, n, m) = tuple(map(int, input().split()))
	a = tuple(map(int, input().split()))
	b = tuple(map(int, input().split()))
	ans = []
	i = 0
	j = 0
	while i + j < n + m:
		if i < n and a[i] == 0:
			ans.append(a[i])
			k += 1
			i += 1
		elif j < m and b[j] == 0:
			ans.append(b[j])
			k += 1
			j += 1
		elif i < n and a[i] <= k:
			ans.append(a[i])
			i += 1
		elif j < m and b[j] <= k:
			ans.append(b[j])
			j += 1
		else:
			ans = [-1]
			break
	print(' '.join(map(str, ans)))


t = int(input())
for u in range(t):
	y = input()
	(k, n, m) = map(int, input().split())
	pol = list(map(int, input().split()))
	mon = list(map(int, input().split()))
	i = 0
	j = 0
	ans = []
	f = 1
	while i < n or j < m:
		if i < n and pol[i] == 0:
			ans.append(pol[i])
			k += 1
			i += 1
		elif j < m and mon[j] == 0:
			ans.append(mon[j])
			k += 1
			j += 1
		elif i < n and pol[i] <= k:
			ans.append(pol[i])
			i += 1
		elif j < m and mon[j] <= k:
			ans.append(mon[j])
			j += 1
		else:
			f = 0
			break
	if f:
		print(*ans)
	else:
		print(-1)


t = int(input())
while t:
	t -= 1
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	run_len = k
	(ai, bi) = (0, 0)
	seq = []
	while ai < len(a) and bi < len(b):
		if a[ai] == 0:
			seq.append(0)
			ai += 1
			run_len += 1
			continue
		if b[bi] == 0:
			seq.append(0)
			bi += 1
			run_len += 1
			continue
		if a[ai] > run_len and b[bi] > run_len:
			seq = []
			break
		if a[ai] < b[bi]:
			seq.append(a[ai])
			ai += 1
		else:
			seq.append(b[bi])
			bi += 1
	while ai < len(a):
		if a[ai] == 0:
			seq.append(0)
			ai += 1
			run_len += 1
		elif a[ai] > run_len:
			seq = []
			break
		else:
			seq.append(a[ai])
			ai += 1
	while bi < len(b):
		if b[bi] == 0:
			seq.append(0)
			bi += 1
			run_len += 1
		elif b[bi] > run_len:
			seq = []
			break
		else:
			seq.append(b[bi])
			bi += 1
	if seq:
		print(' '.join((str(x) for x in seq)))
	else:
		print(-1)


def f(k):
	ans = []
	first = 0
	second = 0
	while first < n or second < m:
		if first < n and a[first] <= k:
			ans.append(a[first])
			if a[first] == 0:
				k += 1
			first += 1
		elif second < m and b[second] <= k:
			ans.append(b[second])
			if b[second] == 0:
				k += 1
			second += 1
		else:
			print(-1)
			break
	else:
		print(' '.join(map(str, ans)))
for t in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f(k)


t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	seq = []
	ns = 0
	ms = 0
	while ns != n or ms != m:
		temp = 0
		while ns < n and (a[ns] == 0 or a[ns] <= k):
			temp = 1
			if a[ns] == 0:
				k += 1
			seq.append(a[ns])
			ns += 1
		while ms < m and (b[ms] == 0 or b[ms] <= k):
			temp = 1
			if b[ms] == 0:
				k += 1
			seq.append(b[ms])
			ms += 1
		if temp == 0:
			break
	if len(seq) == m + n:
		print(*seq)
	else:
		print(-1)


import math

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

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

def I():
	return int(input())

def S():
	return input()

def twoD(row):
	return [L() for i in range(row)]

def fill(val, size):
	return [val] * size

def strToList(s):
	return [s[i] for i in range(len(s))]

def printList(a):
	[print(i, end=' ') for i in a]
	print()

def binary(a):
	return bin(a)[2:]

def decimal(s):
	a = 0
	n = len(s)
	for i in range(n - 1, -1, -1):
		a += int(s[i]) * 2 ** (n - 1 - i)
	return a
for _ in range(I()):
	s = S()
	(k, n, m) = M()
	a = L()
	b = L()
	i = 0
	j = 0
	ans = []
	c = True
	while i < n or j < m:
		if i < n and a[i] == 0:
			k += 1
			ans.append(a[i])
			i += 1
		elif i < n and a[i] <= k:
			ans.append(a[i])
			i += 1
		elif j < m and b[j] == 0:
			k += 1
			ans.append(b[j])
			j += 1
		elif j < m and b[j] <= k:
			ans.append(b[j])
			j += 1
		else:
			c = False
			break
	if c:
		for i in ans:
			print(i, end=' ')
		print()
	else:
		print(-1)


lst = list(map(int, input().split()))
t = lst[0]
for j in range(t):
	res = []
	lst = list(map(str, input().split()))
	lst1 = list(map(int, input().split()))
	k = lst1[0]
	n = lst1[1]
	m = lst1[2]
	lst2 = list(map(int, input().split()))
	lst3 = list(map(int, input().split()))
	i1 = 0
	i2 = 0
	okey = True
	for i in range(n + m):
		ok = False
		if i1 < n:
			if lst2[i1] == 0:
				res = res + ['0']
				k = k + 1
				i1 = i1 + 1
				ok = True
			elif lst2[i1] <= k:
				res = res + [str(lst2[i1])]
				i1 = i1 + 1
				ok = True
		if i2 < m and ok == False:
			if lst3[i2] == 0:
				res = res + ['0']
				k = k + 1
				i2 = i2 + 1
				ok = True
			elif lst3[i2] <= k:
				res = res + [str(lst3[i2])]
				i2 = i2 + 1
				ok = True
		if ok == False:
			okey = False
	if okey:
		print(' '.join(res))
	else:
		print(-1)


t = int(input())
for ii in range(t):
	input()
	(k, n, m) = map(int, input().split())
	an_s = list(map(int, input().split()))
	bm_s = list(map(int, input().split()))
	seq = []
	total = n + m
	ap = 0
	bp = 0
	ac = False
	bc = False
	if an_s[0] > k and bm_s[0] > k:
		print(-1)
		continue
	for i in range(total):
		if ac and bc:
			break
		elif ac:
			small = bm_s[bp]
			bp += 1
		elif bc:
			small = an_s[ap]
			ap += 1
		else:
			small = min(an_s[ap], bm_s[bp])
			if small == an_s[ap]:
				ap += 1
			else:
				bp += 1
		seq.append(small)
		if ap == n:
			ac = True
		if bp == m:
			bc = True
	correct = True
	for i in seq:
		if i == 0:
			k += 1
		if i > k:
			correct = False
	if correct:
		print(*seq)
	else:
		print(-1)


q = int(input())
for v in range(q):
	p = input()
	(x, y, z) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	ans = []
	j = 0
	f = 0
	c = 0
	while i < y or j < z:
		if i < y:
			if a[i] == 0:
				x += 1
				ans.append(a[i])
				i += 1
				continue
			if a[i] <= x:
				ans.append(a[i])
				i += 1
				continue
		if j < z:
			if b[j] == 0:
				x += 1
				ans.append(b[j])
				j += 1
				continue
			if b[j] <= x:
				ans.append(b[j])
				j += 1
				continue
		print(-1)
		f = 1
		break
	if f == 0:
		print(' '.join(map(str, ans)))


def main():
	for _ in range(int(input())):
		input()
		(k, n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		(l, r) = (0, 0)
		f = True
		ans = []
		while l < n and r < m:
			if a[l] == 0:
				ans.append(a[l])
				k += 1
				l += 1
			elif b[r] == 0:
				ans.append(b[r])
				k += 1
				r += 1
			elif a[l] <= k:
				ans.append(a[l])
				l += 1
			elif b[r] <= k:
				ans.append(b[r])
				r += 1
			else:
				f = False
				break
		while l < n:
			if a[l] <= k:
				if a[l] == 0:
					k += 1
				ans.append(a[l])
				l += 1
			else:
				f = False
				break
		while r < m:
			if b[r] <= k:
				if b[r] == 0:
					k += 1
				ans.append(b[r])
				r += 1
			else:
				f = False
				break
		if not f:
			print(-1)
		else:
			print(*ans)
main()


T = int(input())
for i in range(T):
	input()
	(K, N, M) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if A.count(0) + B.count(0) + K < max(A + B):
		print(-1)
	else:
		ans = []
		l_A = 0
		l_B = 0
		for i in range(N + M):
			if l_A < N and l_B < M:
				if A[l_A] < B[l_B]:
					ans.append(A[l_A])
					l_A += 1
				else:
					ans.append(B[l_B])
					l_B += 1
			elif l_A < N:
				ans.append(A[l_A])
				l_A += 1
			else:
				ans.append(B[l_B])
				l_B += 1
		rows = K
		f = True
		for j in range(N + M):
			if ans[j] == 0:
				rows += 1
			elif ans[j] > rows:
				f = False
		if f:
			print(*ans)
		else:
			print(-1)


import heapq, math
from collections import defaultdict, deque
from os import getcwd
import sys, os.path
if os.path.exists('D:\\CP\\programs\\input.txt'):
	sys.stdout = open('D:\\CP\\programs\\output.txt', 'w')
	sys.stdin = open('D:\\CP\\programs\\input.txt', 'r')
input = sys.stdin.readline
test = int(input())
for _ in range(test):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = j = 0
	res = [0] * (n + m)
	flag = True
	idx = 0
	while i < n and j < m:
		if a[i] <= b[j]:
			if a[i] > k:
				flag = False
				break
			res[idx] = a[i]
			if a[i] == 0:
				k += 1
			i += 1
			idx += 1
		else:
			if b[j] > k:
				flag = False
				break
			res[idx] = b[j]
			if b[j] == 0:
				k += 1
			j += 1
			idx += 1
	while i < n and flag == True:
		if a[i] > k:
			flag = False
			break
		else:
			res[idx] = a[i]
			if a[i] == 0:
				k += 1
			i += 1
			idx += 1
	while j < m and flag == True:
		if b[j] > k:
			flag = False
			break
		else:
			res[idx] = b[j]
			if b[j] == 0:
				k += 1
			j += 1
			idx += 1
	if flag:
		print(*res)
	else:
		print('-1')


import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
from collections import Counter
import threading
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 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 SegmentTree1:

	def __init__(self, data, default=10 ** 6, 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)
MOD = 10 ** 9 + 7

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
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10001)]
prime[0] = prime[1] = False

def SieveOfEratosthenes(n=10000):
	p = 2
	c = 0
	while p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				prime[i] = False
		p += 1

class DSU:

	def __init__(self, R, C):
		self.par = range(R * C + 1)
		self.rnk = [0] * (R * C + 1)
		self.sz = [1] * (R * C + 1)

	def find(self, x):
		if self.par[x] != x:
			self.par[x] = self.find(self.par[x])
		return self.par[x]

	def union(self, x, y):
		(xr, yr) = (self.find(x), self.find(y))
		if xr == yr:
			return
		if self.rnk[xr] < self.rnk[yr]:
			(xr, yr) = (yr, xr)
		if self.rnk[xr] == self.rnk[yr]:
			self.rnk[xr] += 1
		self.par[yr] = xr
		self.sz[xr] += self.sz[yr]

	def size(self, x):
		return self.sz[self.find(x)]

	def top(self):
		return self.size(len(self.sz) - 1) - 1

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

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

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = -1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][0] >= key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
t = 1
t = int(input())
for _ in range(t):
	x = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(i, j) = (0, 0)
	res = []
	ch = 1
	line = k
	for x in range(n + m):
		if i < n and a[i] == 0:
			line += 1
			i += 1
			res.append(0)
		elif j < m and b[j] == 0:
			line += 1
			j += 1
			res.append(0)
		elif i < n and a[i] <= line:
			res.append(a[i])
			i += 1
		elif j < m and b[j] <= line:
			res.append(b[j])
			j += 1
		else:
			res = [-1]
			break
	print(*res)


for _ in range(int(input())):
	input()
	(k, m, n) = map(int, input().split())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	i = j = 0
	ans = []
	flag = True
	while i < len(l) and j < len(r):
		if l[i] == 0:
			ans.append(0)
			k += 1
			i += 1
		elif r[j] == 0:
			ans.append(0)
			j += 1
			k += 1
		elif l[i] <= k:
			ans.append(l[i])
			i += 1
		elif r[j] <= k:
			ans.append(r[j])
			j += 1
		else:
			flag = False
			break
	if flag:
		while i < len(l):
			if l[i] <= k:
				ans.append(l[i])
				if l[i] == 0:
					k += 1
				i += 1
			else:
				flag = False
				break
		while j < len(r):
			if r[j] <= k:
				ans.append(r[j])
				if r[j] == 0:
					k += 1
				j += 1
			else:
				flag = False
				break
	if not flag:
		print(-1)
	else:
		print(*ans)


import sys

def process(k, n, m, n_actions, m_actions):
	toreturn = []
	m_counter = 0
	for j in range(n):
		if n_actions[j] == 0:
			toreturn.append(0)
			k += 1
		elif n_actions[j] <= k:
			toreturn.append(n_actions[j])
		else:
			while k < n_actions[j] and m_counter < m:
				if m_actions[m_counter] == 0:
					toreturn.append(0)
					k += 1
					m_counter += 1
				elif m_actions[m_counter] <= k:
					toreturn.append(m_actions[m_counter])
					m_counter += 1
				else:
					return -1
			if n_actions[j] == k:
				toreturn.append(n_actions[j])
			else:
				return -1
	for j in range(m_counter, m):
		if m_actions[j] == 0:
			toreturn.append(0)
			k += 1
		elif m_actions[j] <= k:
			toreturn.append(m_actions[j])
		else:
			return -1
	return toreturn
n = int(input())
for i in range(n):
	dummy = input()
	(k, n, m) = [int(x) for x in input().split()]
	n_actions = [int(x) for x in input().split()]
	m_actions = [int(x) for x in input().split()]
	save = process(k, n, m, n_actions, m_actions)
	if isinstance(save, int):
		print(-1)
	else:
		sys.stdout.write(' '.join(map(str, save)) + '\n')


t = int(input())
for i in range(t):
	input()
	(k, n, m) = list(map(int, input().rstrip().split()))
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	pa = 0
	pb = 0
	s = ''
	flg = True
	while pa < n and pb < m:
		if a[pa] == 0:
			k = k + 1
			s = s + ' ' + str(a[pa])
			pa = pa + 1
		elif a[pa] <= k:
			s = s + ' ' + str(a[pa])
			pa = pa + 1
		elif b[pb] == 0:
			k = k + 1
			s = s + ' ' + str(b[pb])
			pb = pb + 1
		elif b[pb] <= k:
			s = s + ' ' + str(b[pb])
			pb = pb + 1
		else:
			flg = False
			break
	while pa < n:
		if a[pa] == 0:
			k = k + 1
			s = s + ' ' + str(a[pa])
			pa = pa + 1
		elif a[pa] <= k:
			s = s + ' ' + str(a[pa])
			pa = pa + 1
		else:
			flg = False
			break
	while pb < m:
		if b[pb] == 0:
			k = k + 1
			s = s + ' ' + str(b[pb])
			pb = pb + 1
		elif b[pb] <= k:
			s = s + ' ' + str(b[pb])
			pb = pb + 1
		else:
			flg = False
			break
	if flg:
		print(s.lstrip())
	else:
		print(-1)


import sys
from os import path
import collections
from collections import defaultdict
import math
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = int(sys.stdin.readline().rstrip())
p = -1
while t > 0:
	t -= 1
	o = input()
	(k, n, m) = map(int, sys.stdin.readline().rstrip().split())
	a = list(map(int, sys.stdin.readline().rstrip().split()))
	b = list(map(int, sys.stdin.readline().rstrip().split()))
	i = r = 0
	s = ''
	f = 0
	ans = []
	while True:
		if i < n and r < m:
			if a[i] == 0:
				ans.append(a[i])
				k += 1
				i += 1
			elif b[r] == 0:
				ans.append(b[r])
				k += 1
				r += 1
			elif a[i] <= k:
				ans.append(a[i])
				i += 1
			elif b[r] <= k:
				ans.append(b[r])
				r += 1
			else:
				f = 1
				print(p)
				break
		elif i < n and r >= m:
			if a[i] == 0:
				ans.append(a[i])
				k += 1
				i += 1
			elif a[i] <= k:
				ans.append(a[i])
				i += 1
			else:
				f = 1
				print(p)
				break
		elif r < m and i >= n:
			if b[r] == 0:
				ans.append(b[r])
				k += 1
				r += 1
			elif b[r] <= k:
				ans.append(b[r])
				r += 1
			else:
				f = 1
				print(p)
				break
		else:
			break
	if f == 0:
		for x in ans:
			print(x, end=' ')
		print()


for _ in range(int(input())):
	space = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	output = []
	sol = [0] * k
	i = 0
	j = 0
	check = True
	while check and i < len(a) and (j < len(b)):
		if a[i] == 0:
			sol.append(0)
			output.append('0')
			i += 1
		elif b[j] == 0:
			sol.append(0)
			output.append('0')
			j += 1
		elif a[i] <= len(sol):
			output.append(str(a[i]))
			i += 1
		elif b[j] <= len(sol):
			output.append(str(b[j]))
			j += 1
		else:
			check = False
			break
	while check and i < len(a):
		if a[i] == 0:
			sol.append(0)
			output.append('0')
			i += 1
		elif a[i] <= len(sol):
			output.append(str(a[i]))
			i += 1
		else:
			check = False
			break
	while check and j < len(b):
		if b[j] == 0:
			sol.append(0)
			output.append('0')
			j += 1
		elif b[j] <= len(sol):
			output.append(str(b[j]))
			j += 1
		else:
			check = False
			break
	if check:
		print(' '.join(output))
	else:
		print(-1)


t = int(input())
for _ in range(t):
	input()
	(k, n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	res = []
	i = 0
	j = 0
	ans = 1
	for _ in range(n + m):
		if i != n and a[i] <= k and (j == m or a[i] <= b[j]):
			res.append(a[i])
			if a[i] == 0:
				k += 1
			i += 1
		elif j != m and b[j] <= k and (i == n or b[j] < a[i]):
			res.append(b[j])
			if b[j] == 0:
				k += 1
			j += 1
		else:
			ans = 0
			break
	if ans:
		print(*res)
	else:
		print(-1)


for _ in range(int(input())):
	k = input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	L = []
	lines = a.count(0) + b.count(0) + k
	(i, j) = (0, 0)
	d = 0
	if max(a) <= lines and max(b) <= lines:
		Test = True
		while Test:
			if i < n:
				if a[i] > k:
					d += 1
				while a[i] <= k:
					L.append(a[i])
					if a[i] == 0:
						k += 1
						d -= 1
					i += 1
					if i >= n:
						break
			if j < m:
				if b[j] > k:
					d += 1
				while b[j] <= k:
					L.append(b[j])
					if b[j] == 0:
						k += 1
						d -= 1
					j += 1
					if j >= m:
						break
			if i >= n and j >= m or d >= 2:
				break
		if Test and d < 2:
			L = list(map(str, L))
			L = ' '.join(L)
			print(L)
		else:
			print(-1)
	else:
		print(-1)


cases = int(input())
for _ in range(cases):
	input()
	(k, n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))[::-1]
	arr2 = list(map(int, input().split()))[::-1]
	ans = []
	cur_line = k
	for i in range(n + m):
		if arr1 and arr2:
			if arr1[-1] <= arr2[-1]:
				last = arr1.pop()
			else:
				last = arr2.pop()
		elif arr1:
			last = arr1.pop()
		elif arr2:
			last = arr2.pop()
		if last > cur_line:
			print(-1)
			break
		if last == 0:
			cur_line += 1
		ans.append(last)
	else:
		print(*ans)


t = int(input())
for _ in range(t):
	space = input()
	(k, n, m) = list(map(int, input().split()))
	i = j = 0
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	history = []
	while i < n or j < m:
		if i < n and a[i] > 0 and (a[i] <= k):
			history.append(a[i])
			i += 1
		elif i < n and a[i] == 0:
			k += 1
			history.append(0)
			i += 1
		elif j < m and b[j] > 0 and (b[j] <= k):
			history.append(b[j])
			j += 1
		elif j < m and b[j] == 0:
			k += 1
			history.append(0)
			j += 1
		else:
			break
	if i == n and j == m:
		print(' '.join(map(str, history)))
	else:
		print(-1)


for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	(l, r) = (0, 0)
	ans = []
	count = k
	(flag, i) = (0, 0)
	while i < n + m:
		(f1, f2) = (0, 0)
		if l < n and a1[l] <= count:
			if a1[l] == 0:
				count += 1
			ans.append(a1[l])
			l += 1
		elif r < m and a2[r] <= count:
			if a2[r] == 0:
				count += 1
			ans.append(a2[r])
			r += 1
		else:
			flag = 1
			ans = -1
			break
		i += 1
	if flag:
		print(ans)
	else:
		for i in range(m + n):
			print(ans[i], end=' ')
		print()


def work(input):
	result = []
	(k_start, a_count, b_count) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	max_row = k_start
	ia = 0
	ib = 0
	while 1:
		if ia >= a_count and ib >= b_count:
			break
		if ia < a_count:
			if a[ia] == 0:
				result.append(0)
				ia += 1
				max_row += 1
				continue
			elif max_row >= a[ia]:
				result.append(a[ia])
				ia += 1
				continue
		if ib >= b_count:
			return '-1'
		if b[ib] == 0:
			result.append(b[ib])
			ib += 1
			max_row += 1
			continue
		else:
			if b[ib] > max_row:
				return '-1'
			result.append(b[ib])
			ib += 1
	if len(result) == 0:
		return '-1'
	if len(result) == 1:
		return str(result[0])
	return ' '.join(map(str, result))

def main(input, print):
	toPrint = []
	t = int(input())
	for _ in range(t):
		input()
		r = work(input)
		toPrint.append(r)
	print('\n'.join(toPrint))
main(input, print)


import heapq
import sys
from math import *
import threading
from heapq import *
from itertools import count
from pprint import pprint
from collections import defaultdict
from heapq import heapify, heappop, heappush
sys.setrecursionlimit(300000)
mod = 10 ** 9 + 7
inf = 10 ** 15
decision = ['NO', 'YES']
yes = 'YES'
no = 'NO'
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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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 npr(n, r):
	return factorial(n) % mod // (factorial(n - r) % mod) if n >= r else 0

def ncr(n, r):
	return factorial(n) % mod // (factorial(r) * factorial(n - r) % mod) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [{1, i} for i in range(n + 1)]
	p = 2
	while p <= n:
		for i in range(p * 2, n + 1, p):
			prime[i].add(p)
		p += 1
	return prime

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def prod(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def sumk(a, b):
	print('called for', a, b)
	ans = a * (a + 1) // 2
	ans -= b * (b + 1) // 2
	return ans

def sumi(n):
	ans = 0
	if len(n) > 1:
		for x in n:
			ans += int(x)
		return ans
	else:
		return int(n)

def checkwin(x, a):
	if a[0][0] == a[1][1] == a[2][2] == x:
		return 1
	if a[0][2] == a[1][1] == a[2][0] == x:
		return 1
	if len(set(a[0])) == 1 and a[0][0] == x or (len(set(a[1])) == 1 and a[1][0] == x) or (len(set(a[2])) == 1 and a[2][0] == x):
		return 1
	if len(set(a[0][:])) == 1 and a[0][0] == x or (len(set(a[1][:])) == 1 and a[0][1] == x) or (len(set(a[2][:])) == 1 and a[0][0] == x):
		return 1
	return 0
karmanya = int(input())
while karmanya != 0:
	karmanya -= 1
	s = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.append(inf)
	b.append(inf)
	ans = []
	(cnta, cntb) = (0, 0)
	elem = k
	f = 1
	while cnta != n or cntb != m:
		if cnta < n and a[cnta] == 0:
			ans += [0]
			cnta += 1
			elem += 1
		elif cntb < m and b[cntb] == 0:
			ans += [0]
			cntb += 1
			elem += 1
		elif cnta < n and a[cnta] <= elem:
			ans += [a[cnta]]
			cnta += 1
		elif cntb < m and b[cntb] <= elem:
			ans += [b[cntb]]
			cntb += 1
		else:
			ans = [-1]
			break
	print(*ans)


def solve():
	tt = input()
	(k, n, m) = map(int, input().split())
	narr = list(map(int, input().split()))
	marr = list(map(int, input().split()))
	i = 0
	j = 0
	ans = []
	while i < n or j < m:
		flag = 0
		if i < n and narr[i] == 0:
			ans.append(0)
			i += 1
			k += 1
			flag = 1
		elif i < n and narr[i] <= k:
			ans.append(narr[i])
			i += 1
			flag = 1
		if j < m and marr[j] == 0:
			ans.append(0)
			j += 1
			k += 1
			flag = 1
		elif j < m and marr[j] <= k:
			ans.append(marr[j])
			j += 1
			flag = 1
		if flag == 0:
			return -1
	return ans
t = int(input())
for _ in range(t):
	ans = solve()
	if ans == -1:
		print(-1)
	else:
		print(*ans)


def solve(k, n, m, mono, poly):
	(i, j) = (0, 0)
	seq = []
	while i < n and j < m:
		if mono[i] == 0:
			k += 1
			seq.append(str(mono[i]))
			i += 1
		elif mono[i] <= k:
			seq.append(str(mono[i]))
			i += 1
		elif poly[j] == 0:
			k += 1
			seq.append(str(poly[j]))
			j += 1
		elif poly[j] <= k:
			seq.append(str(poly[j]))
			j += 1
		else:
			return -1
	while i < n:
		if mono[i] == 0:
			k += 1
			seq.append(str(mono[i]))
			i += 1
		elif mono[i] <= k:
			seq.append(str(mono[i]))
			i += 1
		else:
			return -1
	while j < m:
		if poly[j] == 0:
			k += 1
			seq.append(str(poly[j]))
			j += 1
		elif poly[j] <= k:
			seq.append(str(poly[j]))
			j += 1
		else:
			return -1
	return ' '.join(seq)
for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	mono = list(map(int, input().split()))
	poly = list(map(int, input().split()))
	print(solve(k, n, m, mono, poly))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	xx = input()
	(k, n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	i = 0
	j = 0
	ans = []
	for ii in range(n + m):
		if i < n and j < m:
			if ar[i] <= br[j]:
				ans.append(ar[i])
				i += 1
			else:
				ans.append(br[j])
				j += 1
		elif i < n:
			ans.append(ar[i])
			i += 1
		else:
			ans.append(br[j])
			j += 1
	flag = True
	for i in ans:
		if i == 0:
			k += 1
		elif i > k:
			flag = False
			break
	if flag:
		print(*ans)
	else:
		print(-1)


t = int(input())
for zzz in range(t):
	input()
	(k, n, m) = map(int, input().split())
	(f, s) = (0, 0)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = ''
	while f < n or s < m:
		if f < n and a[f] == 0:
			k += 1
			f += 1
			ans += '0 '
			continue
		if s < m and b[s] == 0:
			k += 1
			s += 1
			ans += '0 '
			continue
		if f < n and a[f] <= k:
			ans += str(a[f]) + ' '
			f += 1
			continue
		if s < m and b[s] <= k:
			ans += str(b[s]) + ' '
			s += 1
			continue
		print(-1)
		break
	else:
		print(ans)


t = int(input())

def solve():
	input()
	(k, n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	p1 = 0
	p2 = 0
	ans = []
	while p1 < len(arr1) or p2 < len(arr2):
		if p1 < len(arr1) and arr1[p1] <= k:
			if arr1[p1] == 0:
				k += 1
			p1 += 1
			ans.append(arr1[p1 - 1])
		elif p2 < len(arr2) and arr2[p2] <= k:
			if arr2[p2] == 0:
				k += 1
			p2 += 1
			ans.append(arr2[p2 - 1])
		else:
			print('-1')
			return
	print(*ans)
for i in range(t):
	solve()


import sys

def ints():
	return list(map(int, sys.stdin.readline().strip().split()))
tc = int(input())
while tc:
	tc -= 1
	s = input()
	(k, n, m) = map(int, input().split())
	ln = ints()
	lm = ints()
	op = []
	(i, j) = (0, 0)
	while i < n and j < m:
		if ln[i] < lm[j]:
			op.append(ln[i])
			i += 1
		else:
			op.append(lm[j])
			j += 1
	while i < n:
		op.append(ln[i])
		i += 1
	while j < m:
		op.append(lm[j])
		j += 1
	flag = 0
	for item in op:
		if item == 0:
			k += 1
		elif item <= k:
			pass
		else:
			flag = 1
	if flag:
		print(-1)
	else:
		print(*op)


import math
inp = int(input())
for _ in range(inp):
	input()
	(k, n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	i = 0
	j = 0
	res = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			res.append(a[i])
			i += 1
		else:
			res.append(b[j])
			j += 1
	while i < len(a):
		res.append(a[i])
		i += 1
	while j < len(b):
		res.append(b[j])
		j += 1
	flag = True
	for i in res:
		if i == 0:
			k += 1
		elif k < i:
			flag = False
			break
	if flag:
		print(*res)
	else:
		print(-1)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
import math
from bisect import *
from heapq import *
from collections import defaultdict as dd
from collections import OrderedDict as odict
from collections import Counter as cc
from collections import deque
from itertools import groupby
sys.setrecursionlimit(20 * 20 * 20 * 20 + 10)

def solve():
	input()
	(k, n, m) = takeivr()
	arr1 = takeiar()
	arr2 = takeiar()
	first = second = 0
	ans = []
	while first < n and second < m:
		if arr1[first] < arr2[second]:
			ans.append(arr1[first])
			first += 1
		else:
			ans.append(arr2[second])
			second += 1
	for i in range(first, n):
		ans.append(arr1[i])
	for i in range(second, m):
		ans.append(arr2[i])
	for i in range(n + m):
		if ans[i] != 0:
			if k < ans[i]:
				print(-1)
				return
		else:
			k += 1
	print(*ans)
	return

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

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

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

def takeiar():
	return list(map(int, sys.stdin.readline().rstrip('\r\n').split()))

def takesar():
	return list(map(str, sys.stdin.readline().rstrip('\r\n').split()))

def takeivr():
	return map(int, sys.stdin.readline().rstrip('\r\n').split())

def takesvr():
	return map(str, sys.stdin.readline().rstrip('\r\n').split())

def ispalindrome(s):
	return s == s[::-1]

def invert(bit_s):
	temp = int(bit_s, 2)
	inverse_s = temp ^ 2 ** (len(bit_s) + 1) - 1
	rslt = bin(inverse_s)[3:]
	return str(rslt)

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

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


def verify_result(k, arr):
	for i in arr:
		if i == 0:
			k += 1
		elif k >= i:
			continue
		else:
			return [-1]
	return arr

def solve():
	input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p1 = 0
	p2 = 0
	result = []
	while p1 < n or p2 < m:
		value_1 = float('inf')
		value_2 = float('inf')
		if p1 < n:
			value_1 = a[p1]
			if value_1 == 0:
				result.append(value_1)
				p1 += 1
				continue
		if p2 < m:
			value_2 = b[p2]
			if value_2 == 0:
				result.append(value_2)
				p2 += 1
				continue
		if value_1 < value_2:
			result.append(value_1)
			p1 += 1
			continue
		else:
			result.append(value_2)
			p2 += 1
			continue
	print(*verify_result(k, result), sep=' ')
for i in range(int(input())):
	solve()


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

def solve():
	input()
	(k, n, m) = tuple(read_ints())
	a = read_ints()
	b = read_ints()
	indA = 0
	indB = 0
	res = []
	while indA != n or indB != m:
		if indA == n:
			cand = b[indB]
			indB += 1
		elif indB == m:
			cand = a[indA]
			indA += 1
		elif a[indA] < b[indB]:
			cand = a[indA]
			indA += 1
		else:
			cand = b[indB]
			indB += 1
		if cand > k:
			print(-1)
			return
		if cand == 0:
			k += 1
		res.append(cand)
	print(' '.join([str(x) for x in res]))
t = int(input())
for i in range(t):
	solve()


for q in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = [i for i in map(int, input().split())]
	b = [i for i in map(int, input().split())]
	al = bl = 0
	f = True
	end = False
	ans = []
	good = True
	while al + bl != n + m:
		if al != n and a[al] > k and (bl != m) and (b[bl] > k):
			print(-1)
			good = False
			break
		if f:
			if al == n:
				f = False
				end = True
			elif a[al] == 0:
				k += 1
				ans.append(a[al])
				al += 1
			elif a[al] <= k:
				ans.append(a[al])
				al += 1
			elif a[al] > k:
				if end:
					print(-1)
					good = False
					break
				f = False
		elif bl == m:
			f = end = True
		elif b[bl] == 0:
			k += 1
			ans.append(b[bl])
			bl += 1
		elif b[bl] <= k:
			ans.append(b[bl])
			bl += 1
		elif b[bl] > k:
			if end:
				print(-1)
				good = False
				break
			f = True
	if good:
		print(' '.join(map(str, ans)))


import os
import sys
from math import ceil, floor, sqrt, gcd, factorial
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 main():
	alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	for _ in range(int(input())):
		input()
		(k, n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		i = 0
		j = 0
		ans = []
		fa = True
		fb = False
		pas = 0
		pasf = False
		while i < n or j < m:
			if pas >= 2:
				pasf = True
				break
			if fa == True:
				if a[i] == 0:
					pas = 0
					k += 1
					ans.append(a[i])
					i += 1
				elif a[i] <= k:
					pas = 0
					ans.append(a[i])
					i += 1
				else:
					pas += 1
					fa = False
					fb = True
				if i == n:
					for o in b[j:]:
						if o == 0:
							ans.append(o)
							k += 1
						elif o <= k:
							ans.append(o)
						else:
							pasf = True
							break
					break
			else:
				if b[j] == 0:
					pas = 0
					k += 1
					ans.append(b[j])
					j += 1
				elif b[j] <= k:
					pas = 0
					ans.append(b[j])
					j += 1
				else:
					pas += 1
					fa = True
					fb = False
				if j == m:
					for o in a[i:]:
						if o == 0:
							ans.append(o)
							k += 1
						elif o <= k:
							ans.append(o)
						else:
							pasf = True
							break
					break
		if pasf == False:
			print(*ans)
		else:
			print(-1)
main()


t = int(input())
for _ in range(t):
	input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	ai = 0
	bi = 0
	cur_pages = k
	while ai < len(a) or bi < len(b):
		if ai < len(a) and a[ai] == 0:
			c.append(0)
			cur_pages += 1
			ai += 1
		elif ai < len(a) and cur_pages >= a[ai]:
			c.append(a[ai])
			ai += 1
		elif bi < len(b) and b[bi] == 0:
			c.append(0)
			cur_pages += 1
			bi += 1
		elif bi < len(b) and b[bi] <= cur_pages:
			c.append(b[bi])
			bi += 1
		else:
			print('-1')
			break
	if len(c) == len(a) + len(b):
		print(' '.join(map(str, c)))


secuencias = int(input())
input()
for x in range(secuencias):
	(k, n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if x != secuencias - 1:
		input()
	(i, j) = (0, 0)
	error = False
	pasos = []
	while i < n or j < m:
		if i < n and j < m:
			if a[i] == 0:
				pasos.append(0)
				i += 1
				k += 1
			elif b[j] == 0:
				pasos.append(0)
				j += 1
				k += 1
			elif a[i] < b[j] and a[i] <= k:
				pasos.append(a[i])
				i += 1
			elif a[i] >= b[j] and b[j] <= k:
				pasos.append(b[j])
				j += 1
			else:
				print(-1)
				error = True
				break
		elif i < n:
			if a[i] == 0:
				pasos.append(0)
				i += 1
				k += 1
			elif a[i] <= k:
				pasos.append(a[i])
				i += 1
			else:
				print(-1)
				error = True
				break
		elif j < m:
			if b[j] == 0:
				pasos.append(0)
				j += 1
				k += 1
			elif b[j] <= k:
				pasos.append(b[j])
				j += 1
			else:
				print(-1)
				error = True
				break
	if not error:
		print(' '.join([str(int) for int in pasos]))


tt = int(input())
for _ in range(tt):
	empt = input()
	(k, n, m) = list(map(int, input().split(' ')))
	ai = list(map(int, input().split(' ')))
	bi = list(map(int, input().split(' ')))
	numlines = k
	ans = []
	for i in range(n + m):
		am = ai[0] if ai else -1
		bm = bi[0] if bi else -1
		if am > 0 and am <= numlines:
			ans.append(str(am))
			ai = ai[1:]
		elif bm > 0 and bm <= numlines:
			ans.append(str(bm))
			bi = bi[1:]
		elif am == 0:
			numlines += 1
			ans.append(str(am))
			ai = ai[1:]
		elif bm == 0:
			numlines += 1
			ans.append(str(bm))
			bi = bi[1:]
		else:
			ans = [-1]
			break
	print(*ans, sep=' ')


t = int(input())
for _ in range(t):
	bb = input().split()
	while bb == []:
		bb = input().split()
	(k, n, m) = (int(bb[0]), int(bb[1]), int(bb[2]))
	s1 = input().split()
	s2 = input().split()
	for i in range(n):
		s1[i] = int(s1[i])
	for i in range(m):
		s2[i] = int(s2[i])
	l = 0
	r = 0
	out = []
	flag = True
	(n, m) = (m, n)
	while l < m or r < n:
		if l == m:
			if s2[r] > k:
				if s2[r] == 0:
					out.append(s2[r])
					r += 1
					k += 1
				else:
					print(-1)
					flag = False
					break
			elif s2[r] <= k:
				out.append(s2[r])
				if s2[r] == 0:
					k += 1
				r += 1
		elif r == n:
			if s1[l] > k:
				if s1[l] == 0:
					out.append(s1[l])
					l += 1
					k += 1
				else:
					print(-1)
					flag = False
					break
			elif s1[l] <= k:
				out.append(s1[l])
				if s1[l] == 0:
					k += 1
				l += 1
		elif min(s1[l], s2[r]) > k:
			maa = min(s1[l], s2[r])
			if maa == 0:
				out.append(maa)
				if maa == s1[l]:
					l += 1
				else:
					r += 1
				k += 1
			else:
				print(-1)
				flag = False
				break
		elif min(s1[l], s2[r]) <= k:
			maa = min(s1[l], s2[r])
			if maa == 0:
				k += 1
			out.append(maa)
			if maa == s1[l]:
				l += 1
			else:
				r += 1
	if flag == False:
		continue
	print(*out)


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def solve_():
	_ = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = []
	x = 0
	y = 0
	while x < n or y < m:
		if x < n and a[x] == 0:
			s.append(0)
			k += 1
			x += 1
		elif y < m and b[y] == 0:
			s.append(0)
			k += 1
			y += 1
		elif x < n and a[x] <= k:
			s.append(a[x])
			x += 1
		elif y < m and b[y] <= k:
			s.append(b[y])
			y += 1
		else:
			return [-1]
	return s
for case_num in range(int(input())):
	res = solve()
	print(*res)


T = int(input())
while T > 0:
	T -= 1
	input()
	(k, a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	buff = k
	(ai, bi) = (0, 0)
	failed = False
	order = []
	for i in range(a + b):
		if ai < len(arr) and arr[ai] <= buff:
			if arr[ai] == 0:
				buff += 1
			order.append(arr[ai])
			ai += 1
			continue
		if bi < len(brr) and brr[bi] <= buff:
			if brr[bi] == 0:
				buff += 1
			order.append(brr[bi])
			bi += 1
			continue
		failed = True
		break
	if failed:
		print(-1)
	else:
		print(' '.join(map(str, order)))


for _ in range(int(input())):
	input()
	(k, n, m) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	sequence = [''] * (n + m)
	(i, j) = (0, 0)
	while True:
		if i < n and a[i] == 0:
			sequence[i + j] = '0'
			k += 1
			i += 1
		elif j < m and b[j] == 0:
			sequence[i + j] = '0'
			k += 1
			j += 1
		elif i < n and a[i] <= k:
			sequence[i + j] = str(a[i])
			i += 1
		elif j < m and b[j] <= k:
			sequence[i + j] = str(b[j])
			j += 1
		else:
			break
	if i == n and j == m:
		print(' '.join(sequence))
	else:
		print('-1')


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()
dtoa = 'abcdefghijklmnopqrstuvwxyz'
atod = {'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=False)

def matrix(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 solve():
	(k, n, m) = li()
	a = li()
	b = li()
	pa = pb = 0
	pages = k
	actions = []
	while pa < len(a) or pb < len(b):
		count = 0
		while pa < len(a):
			if a[pa] == 0:
				actions.append(a[pa])
				pages += 1
				count += 1
				pa += 1
			elif a[pa] <= pages:
				actions.append(a[pa])
				count += 1
				pa += 1
			else:
				break
		while pb < len(b):
			if b[pb] == 0:
				actions.append(b[pb])
				pages += 1
				count += 1
				pb += 1
			elif b[pb] <= pages:
				actions.append(b[pb])
				count += 1
				pb += 1
			else:
				break
		if count == 0:
			return -1
	return actions

def main():
	for _ in range(ii()):
		input()
		ans = solve()
		if ans == -1:
			print(ans)
		else:
			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')

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
import string
from decimal import Decimal
from math import log

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

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

def inpstrlist():
	s = input()
	return list(s[:len(s)])

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

def printlist(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')
t = inp()
for _ in range(t):
	space = input()
	(k, n, m) = invr()
	A = inplist()
	B = inplist()
	i = 0
	j = 0
	ans = []
	flag = 0
	while i != n and j != m:
		if A[i] == 0:
			ans.append(A[i])
			i += 1
			k += 1
		elif B[j] == 0:
			ans.append(B[j])
			j += 1
			k += 1
		elif A[i] <= B[j]:
			if A[i] <= k:
				ans.append(A[i])
				i += 1
			else:
				flag = 1
				break
		elif B[j] <= k:
			ans.append(B[j])
			j += 1
		else:
			flag = 1
			break
	while i != n:
		if A[i] == 0:
			ans.append(A[i])
			k += 1
		elif A[i] <= k:
			ans.append(A[i])
		else:
			flag = 1
			break
		i += 1
	while j != m:
		if B[j] == 0:
			ans.append(B[j])
			k += 1
		elif B[j] <= k:
			ans.append(B[j])
		else:
			flag = 1
			break
		j += 1
	if flag:
		print(-1)
	else:
		print(*ans)


t = int(input())
for j in range(t):
	s = input()
	flag = 0
	(k, n, m) = map(int, input().split(' '))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	seq = ''
	while n > 0 or m > 0:
		if n > 0 and a[0] == 0:
			seq += '0 '
			k += 1
			a.pop(0)
			n -= 1
		elif n > 0 and a[0] <= k:
			seq += str(a[0]) + ' '
			a.pop(0)
			n -= 1
		elif m > 0 and b[0] == 0:
			seq += '0 '
			b.pop(0)
			k += 1
			m -= 1
		elif m > 0 and b[0] <= k:
			seq += str(b[0]) + ' '
			b.pop(0)
			m -= 1
		else:
			flag = 1
			print(-1)
			break
	if flag == 0:
		print(seq)


t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	j = 0
	flag = 1
	ans = []
	while i < n or j < m:
		while i < n:
			if a[i] == 0:
				k += 1
				ans.append(a[i])
			elif a[i] > k:
				break
			else:
				ans.append(a[i])
			i += 1
		while j < m:
			if b[j] == 0:
				k += 1
				ans.append(b[j])
			elif b[j] > k:
				break
			else:
				ans.append(b[j])
			j += 1
		if i < n and j < m and (a[i] > k) and (b[j] > k) or (i == n and j < m and (b[j] > k)) or (i < n and j == m and (a[i] > k)):
			flag = -1
			break
	if flag == -1:
		print(-1)
	else:
		print(*ans)


import sys
input = sys.stdin.readline

def solve():
	input()
	(k, n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	(i, j) = (0, 0)
	flag = 1
	ans = []
	while i < n and j < m:
		if A[i] > k and B[j] > k:
			print(-1)
			return
		if flag:
			if A[i] == 0:
				k += 1
				ans.append(A[i])
				i += 1
				continue
			elif A[i] <= k:
				ans.append(A[i])
				i += 1
				continue
			else:
				flag = 0
		elif B[j] == 0:
			ans.append(B[j])
			k += 1
			j += 1
			continue
		elif B[j] <= k:
			ans.append(B[j])
			j += 1
			continue
		else:
			flag = 1
	if i == n:
		while j < m:
			if B[j] == 0:
				ans.append(B[j])
				k += 1
				j += 1
				continue
			elif B[j] <= k:
				ans.append(B[j])
				j += 1
				continue
			else:
				print(-1)
				return
	if j == m:
		while i < n:
			if A[i] == 0:
				k += 1
				ans.append(A[i])
				i += 1
				continue
			elif A[i] <= k:
				ans.append(A[i])
				i += 1
				continue
			else:
				print(-1)
				return
	print(*ans)
for _ in range(int(input())):
	solve()


from sys import stdin

def A():
	t = int(stdin.readline())
	while t:
		aaa = stdin.readline()
		t -= 1
		d = [int(x) for x in stdin.readline().split()]
		(xa, ya) = (d[0], d[1])
		c = [int(x) for x in stdin.readline().split()]
		(xb, yb) = (c[0], c[1])
		b = [int(x) for x in stdin.readline().split()]
		(xf, yf) = (b[0], b[1])
		res = abs(xa - xb) + abs(ya - yb)
		if xa == xb == xf and min(ya, yb) < yf < max(ya, yb):
			res += 2
		elif ya == yb == yf and min(xa, xb) < xf < max(xa, xb):
			res += 2
		print(res)

def B():
	t = int(stdin.readline())
	while t:
		s = input()
		t -= 1
		s1 = []
		for i in s:
			s1.append(ord(i) - ord('a'))
		sav = max(s1)
		l = 0
		r1 = len(s1) - 1
		res = True
		k = [0] * 30
		for i in s1:
			if k[i] > 1:
				res = False
				break
			k[i] += 1
		for i in k:
			if i > 1:
				res = False
				break
		if len(s1) > 1 and res:
			while sav == s1[l] or sav == s1[r1]:
				if sav == s1[l] == s1[r1]:
					res = False
					break
				if sav == s1[l]:
					l += 1
				elif sav == s1[r1]:
					r1 -= 1
				else:
					res = False
					break
				sav -= 1
				if sav <= 0 or l >= r1:
					break
		if sav <= 0 and res:
			print('YES')
		else:
			print('NO')

def C():
	t = int(stdin.readline())
	while t:
		aaa = stdin.readline()
		t -= 1
		d = [int(x) for x in stdin.readline().split()]
		(k, n, m) = (d[0], d[1], d[2])
		a = [int(x) for x in stdin.readline().split()]
		b = [int(x) for x in stdin.readline().split()]
		l = 0
		l1 = 0
		res = []
		sav = True
		while l != n or l1 != m:
			if l != n and a[l] == 0:
				res.append(0)
				k += 1
				l += 1
			elif l1 != m and b[l1] == 0:
				res.append(0)
				k += 1
				l1 += 1
			elif l != n and a[l] <= k:
				res.append(a[l])
				l += 1
			elif l1 != m and b[l1] <= k:
				res.append(b[l1])
				l1 += 1
			else:
				print(-1)
				sav = False
				break
		if sav:
			for i in res:
				print(i, end=' ')
			print()
C()


t = int(input())
for w in range(t):
	st = input()
	(k, n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.reverse()
	b.reverse()
	v = []
	flag = 0
	while len(a) > 0 and len(b) > 0:
		x = a.pop()
		y = b.pop()
		if x == 0:
			v.append(0)
			b.append(y)
			k += 1
			continue
		if y == 0:
			v.append(0)
			a.append(x)
			k += 1
			continue
		if x <= k:
			v.append(x)
			b.append(y)
			continue
		if y <= k:
			v.append(y)
			a.append(x)
			continue
		else:
			flag = 1
			break
	while len(a) > 0:
		x = a.pop()
		if x == 0:
			v.append(0)
			k += 1
			continue
		if x <= k:
			v.append(x)
		else:
			flag = 1
			break
	while len(b) > 0:
		x = b.pop()
		if x == 0:
			v.append(0)
			k += 1
			continue
		if x <= k:
			v.append(x)
		else:
			flag = 1
			break
	if flag == 1:
		print('-1')
	else:
		print(*v, sep=' ')


for _ in range(int(input())):
	s = input()
	k = 0
	(n, a, b) = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	d = max(max(l1), max(l2)) + 1
	l1.append(d)
	l2.append(d)
	i = 0
	j = 0
	l = []
	while i + j < a + b:
		if l1[i] <= l2[j]:
			if l1[i] <= n:
				l.append(l1[i])
				if l1[i] == 0:
					n += 1
				i += 1
			else:
				k = 1
				break
		elif l1[i] > l2[j]:
			if l2[j] <= n:
				l.append(l2[j])
				j += 1
				if l2[j - 1] == 0:
					n += 1
			else:
				k = 1
				break
		else:
			k = 1
			break
	if k:
		print(-1)
	else:
		print(*l)


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())
for _ in range(ii()):
	input()
	(k, m, n) = mi()
	a = li()
	b = li()
	l = []
	p = 0
	i = 0
	j = 0
	f = 1
	while p < m + n:
		p += 1
		if i < m and k >= a[i]:
			if a[i]:
				l.append(a[i])
			else:
				l.append(a[i])
				k += 1
			i += 1
		elif j < n and k >= b[j]:
			if b[j]:
				l.append(b[j])
			else:
				l.append(b[j])
				k += 1
			j += 1
		else:
			f = 0
			break
	if f:
		for i in l:
			print(i, end=' ')
		print()
	else:
		print(-1)


t = int(input())
for _ in range(t):
	input()
	(k, n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ai = 0
	bi = 0
	change = 0
	pred_change = 0
	res = []
	while ai < n or bi < m:
		while ai < n and a[ai] <= k:
			res.append(a[ai])
			if a[ai] == 0:
				k += 1
			ai += 1
			change += 1
		while bi < m and b[bi] <= k:
			res.append(b[bi])
			if b[bi] == 0:
				k += 1
			bi += 1
			change += 1
		if change == pred_change:
			res = [-1]
			break
		pred_change = change
	for i in res:
		print(i, end=' ')
	print()


T = int(input())
for t in range(T):
	z = str(input())
	knm = list(map(int, input().split()))
	(k, n, m) = (knm[0], knm[1], knm[2])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(i, j) = (0, 0)
	sol = []
	flag = 0
	while i != n or j != m:
		if i != n and a[i] == 0:
			sol.append(0)
			k += 1
			i += 1
		elif j != m and b[j] == 0:
			sol.append(0)
			k += 1
			j += 1
		elif i != n and a[i] <= k:
			sol.append(a[i])
			i += 1
		elif j != m and b[j] <= k:
			sol.append(b[j])
			j += 1
		else:
			print(-1)
			flag = 1
			break
	if not flag:
		print(' '.join(map(str, sol)))


t = int(input())
for p in range(t):
	bull = input()
	l = list(map(int, input().rstrip().split()))
	k = l[0]
	n = l[1]
	m = l[2]
	l1 = list(map(int, input().rstrip().split()))
	l2 = list(map(int, input().rstrip().split()))
	f = 1
	x = max(l1)
	y = max(l2)
	z = max(x, y)
	z1 = l1.count(0)
	z2 = l2.count(0)
	res = []
	if z > z1 + z2 + k:
		f = 0
	else:
		i = 0
		j = 0
		while i < n and j < m:
			if l1[i] <= l2[j]:
				res.append(l1[i])
				i += 1
			else:
				res.append(l2[j])
				j += 1
		if i < n:
			for h in range(i, n):
				res.append(l1[h])
		elif j < m:
			for q in range(j, m):
				res.append(l2[q])
		sum = k
		for b in range(len(res)):
			if res[b] == 0:
				sum += 1
			elif res[b] > sum:
				f = 0
	if f == 1:
		for v in range(len(res)):
			print(res[v], end=' ')
	else:
		print(-1)
	print('\n')


for t in range(int(input())):
	res = True
	seq = []
	input()
	(k, n, m) = map(int, input().split())
	lst_n = list(map(int, input().split()))
	lst_m = list(map(int, input().split()))
	for i in range(n + m):
		if len(lst_n) > 0:
			if lst_n[0] > k:
				if len(lst_m) > 0:
					if lst_m[0] == 0:
						k += 1
						seq.append(lst_m[0])
						lst_m.pop(0)
					elif lst_m[0] <= k:
						seq.append(lst_m[0])
						lst_m.pop(0)
					else:
						res = False
						break
				else:
					res = False
					break
			elif lst_n[0] == 0:
				k += 1
				seq.append(lst_n[0])
				lst_n.pop(0)
			elif lst_n[0] <= k:
				seq.append(lst_n[0])
				lst_n.pop(0)
	if len(lst_m) > 0:
		for l in lst_m:
			if l == 0:
				k += 1
				seq.append(l)
			elif l <= k:
				seq.append(l)
			else:
				res = False
				break
	if res:
		for s in seq:
			print(s, '', end='')
		print()
	else:
		print(-1)


def seq(k, s1, s2):
	i = 0
	j = 0
	s = []
	while True:
		if i >= len(s1):
			break
		if j >= len(s2):
			break
		if s1[i] <= k:
			s.append(s1[i])
			if s1[i] == 0:
				k += 1
			i += 1
		elif s2[j] <= k:
			s.append(s2[j])
			if s2[j] == 0:
				k += 1
			j += 1
		else:
			return [-1]
	while i < len(s1):
		if s1[i] <= k:
			s.append(s1[i])
			if s1[i] == 0:
				k += 1
			i += 1
		else:
			return [-1]
	while j < len(s2):
		if s2[j] <= k:
			s.append(s2[j])
			if s2[j] == 0:
				k += 1
			j += 1
		else:
			return [-1]
	return s

def draw(a):
	for i in range(len(a)):
		print(a[i], end=' ')
	print()
N = int(input())
for i in range(N):
	whitespace = input()
	(k, m, n) = list(map(int, input().split()))
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	draw(seq(k, s1, s2))


def main():
	t = int(input())
	for _ in range(t):
		input()
		(k, n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		sequense = ''
		indexA = 0
		indexB = 0
		while True:
			if indexA == n and indexB == m:
				break
			if indexA < n and a[indexA] <= k and (a[indexA] != 0):
				sequense += str(a[indexA]) + ' '
				indexA += 1
			elif indexB < m and b[indexB] <= k and (b[indexB] != 0):
				sequense += str(b[indexB]) + ' '
				indexB += 1
			elif indexA < n and a[indexA] == 0:
				sequense += str(a[indexA]) + ' '
				indexA += 1
				k += 1
			elif indexB < m and b[indexB] == 0:
				sequense += str(b[indexB]) + ' '
				indexB += 1
				k += 1
			else:
				sequense = '-1 '
				break
		print(sequense[:len(sequense) - 1])
main()


for _ in range(int(input())):
	a = input()
	(k, n, m) = [int(a) for a in input().split()]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	j = 0
	ch = ''
	B = True
	while (i < n or j < m) and B:
		B = False
		if i < n and a[i] <= k:
			ch += ' ' + str(a[i])
			if a[i] == 0:
				k += 1
			i += 1
			B = True
		if j < m and b[j] <= k:
			ch += ' ' + str(b[j])
			if b[j] == 0:
				k += 1
			j += 1
			B = True
	if B == False:
		print('-1')
	else:
		print(ch[1:])


def solve():
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = []
	i = 0
	j = 0
	while True:
		if i < n and a[i] == 0:
			res.append(a[i])
			i += 1
			k += 1
		elif j < m and b[j] == 0:
			res.append(b[j])
			j += 1
			k += 1
			continue
		elif i < n and a[i] > 0 and (a[i] <= k):
			res.append(a[i])
			i += 1
		elif j < m and b[j] > 0 and (b[j] <= k):
			res.append(b[j])
			j += 1
		else:
			break
	if len(res) == n + m:
		print(*res)
	else:
		print(-1)
for i in range(int(input())):
	solve()


import sys, os
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
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')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
from math import *
tc = 1
tc = int(input())
for test in range(1, tc + 1):
	empty = input()
	(k, n, m) = inp()
	a = inp()[::-1]
	b = inp()[::-1]
	ans = []
	while a and b:
		if a[-1] < b[-1]:
			ans.append(a.pop())
		else:
			ans.append(b.pop())

	def valid(ans):
		n = len(ans)
		lol = [0] * k
		for i in ans:
			if i == 0:
				lol.append(0)
			elif i > len(lol):
				return False
		return True
	ans.extend(a[::-1])
	ans.extend(b[::-1])
	if valid(ans):
		print(*ans)
	else:
		print(-1)


def solve(k, tab1, tab2):
	res = []
	nbLine = k
	while len(tab1) > 0 or len(tab2) > 0:
		choice1 = 500
		choice2 = 500
		if tab1:
			choice1 = tab1[0]
		if tab2:
			choice2 = tab2[0]
		if choice1 == 0:
			res.append(0)
			nbLine += 1
			del tab1[0]
		elif choice2 == 0:
			res.append(0)
			nbLine += 1
			del tab2[0]
		elif min(choice1, choice2) <= nbLine:
			if choice1 <= nbLine:
				res.append(choice1)
				del tab1[0]
			elif choice2 <= nbLine:
				res.append(choice2)
				del tab2[0]
		else:
			return [-1]
	return res
t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	tab1 = list(map(int, input().split()))
	tab2 = list(map(int, input().split()))
	res = solve(k, tab1, tab2)
	print(' '.join(list(map(str, res))))


for i in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	l = []
	q = n + m
	(w, e, t) = (0, 0, 1)
	while q:
		if w < n and a[w] == 0:
			l += [a[w]]
			w += 1
			k += 1
		elif w < n and a[w] <= k:
			l += [a[w]]
			w += 1
		elif e < m and b[e] == 0:
			l += [b[e]]
			e += 1
			k += 1
		elif e < m and b[e] <= k:
			l += [b[e]]
			e += 1
		else:
			t = 0
			break
		q -= 1
	if l and t:
		print(*l)
	else:
		print(-1)


from sys import stdin, stdout
ip = lambda : stdin.readline().rstrip('\r\n')
ips = lambda : ip().split()
out = lambda x, end='\n': stdout.write(str(x) + end)
for _ in range(int(ip())):
	s = ip()
	(k, n, m) = map(int, ips())
	a = list(map(int, ips()))
	b = list(map(int, ips()))
	(i, j) = (0, 0)
	ans = []
	while i < n or j < m:
		if i < n:
			if a[i] == 0:
				k += 1
				ans.append(0)
				i += 1
			elif k >= a[i]:
				ans.append(a[i])
				i += 1
			elif j < m:
				if b[j] == 0:
					k += 1
					ans.append(0)
					j += 1
				elif k >= b[j]:
					ans.append(b[j])
					j += 1
				else:
					out(-1)
					break
			else:
				out(-1)
				break
		elif j < m:
			if b[j] == 0:
				k += 1
				ans.append(0)
				j += 1
			elif k >= b[j]:
				ans.append(b[j])
				j += 1
			else:
				out(-1)
				break
	else:
		print(*ans)


cases = int(input())
for c in range(cases):
	_ = input()
	(k, *_) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	s = []
	possible = True
	while len(a) > 0 and len(b) > 0:
		if a[0] <= k:
			act = a.pop(0)
			s.append(act)
			if act == 0:
				k += 1
		elif b[0] <= k:
			act = b.pop(0)
			s.append(act)
			if act == 0:
				k += 1
		else:
			possible = False
			break
	if len(a) == 0:
		for act in b:
			if act <= k:
				s.append(act)
				if act == 0:
					k += 1
			else:
				possible = False
				break
	elif len(b) == 0:
		for act in a:
			if act <= k:
				s.append(act)
				if act == 0:
					k += 1
			else:
				possible = False
				break
	if possible:
		s = [str(act) for act in s]
		print(' '.join(s))
	else:
		print(-1)


def f(k, List1, List2):
	s = []
	while List1 != [] or List2 != []:
		if List1 == []:
			b1 = List2[0]
			if b1 == 0:
				s += [0]
				k += 1
				List2 = List2[1:]
			elif k < b1:
				return [-1]
			else:
				s += [b1]
				List2 = List2[1:]
		elif List2 == []:
			a1 = List1[0]
			if a1 == 0:
				s += [0]
				k += 1
				List1 = List1[1:]
			elif k < a1:
				return [-1]
			else:
				s += [a1]
				List1 = List1[1:]
		else:
			a1 = List1[0]
			b1 = List2[0]
			if b1 == 0:
				s += [0]
				k += 1
				List2 = List2[1:]
			elif a1 == 0:
				s += [0]
				k += 1
				List1 = List1[1:]
			elif k >= a1:
				s += [a1]
				List1 = List1[1:]
			elif k >= b1:
				s += [b1]
				List2 = List2[1:]
			else:
				return [-1]
	else:
		return s
t = int(input())
for i in range(t):
	space = input()
	kmn = list(map(int, input().rstrip().split()))
	k = kmn[0]
	List1 = list(map(int, input().rstrip().split()))
	List2 = list(map(int, input().rstrip().split()))
	ans = f(k, List1, List2)
	print(' '.join(map(str, ans)))


import os, 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 math import ceil
mod = 10 ** 9 + 7
for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	mono = list(map(int, input().split()))
	poly = list(map(int, input().split()))
	order = []
	(i, j) = (0, 0)
	flag = 0
	while i < n or j < m:
		flag = 0
		while i < n:
			if mono[i] == 0:
				k += 1
				i += 1
				order.append(0)
			elif mono[i] <= k:
				order.append(mono[i])
				i += 1
			elif mono[i] > k:
				while j < m:
					if poly[j] == 0:
						order.append(0)
						j += 1
						k += 1
					elif poly[j] <= k:
						order.append(poly[j])
						j += 1
					else:
						break
				if mono[i] <= k:
					order.append(mono[i])
					i += 1
				else:
					flag = 1
					break
		if flag:
			break
		while j < m:
			if poly[j] == 0:
				k += 1
				j += 1
				order.append(0)
			elif poly[j] <= k:
				order.append(poly[j])
				j += 1
			elif poly[j] > k:
				while i < n:
					if mono[i] == 0:
						order.append(0)
						j += 1
						k += 1
					elif mono[i] <= k:
						order.append(mono[i])
						i += 1
					else:
						break
				if poly[j] <= k:
					order.append(poly[j])
					j += 1
				else:
					flag = 1
					break
		if flag:
			break
	if flag:
		print(-1)
	else:
		print(*order)


for _ in range(int(input())):
	tab = input()
	(k, n, m) = map(int, input().split())
	listn = list(map(int, input().split()))
	listm = list(map(int, input().split()))
	ans = []
	status = True
	stuck = False
	noOfTries = 0
	while len(listm) > 0 or len(listn) > 0:
		if noOfTries > 3:
			break
		if len(listn) == 0:
			status = False
			noOfTries += 1
		if len(listm) == 0:
			status = True
			noOfTries += 1
		if status and listn[0] != 0:
			if k >= listn[0]:
				ans.append(listn[0])
				listn = listn[1:]
				noOfTries = 0
			else:
				status = False
				noOfTries += 1
		elif status and listn[0] == 0:
			ans.append(listn[0])
			listn = listn[1:]
			noOfTries = 0
			k += 1
		elif not status and listm[0] != 0:
			if k >= listm[0]:
				ans.append(listm[0])
				listm = listm[1:]
				noOfTries = 0
			else:
				status = True
				noOfTries += 1
		else:
			ans.append(listm[0])
			listm = listm[1:]
			noOfTries = 0
			k += 1
	if noOfTries > 3:
		print(-1)
	else:
		ans = list(map(str, ans))
		print(' '.join(ans))


for _ in range(int(input())):
	input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = []
	for i in range(n + m):
		if len(a) > 0:
			if a[0] == 0:
				k += 1
				ans.append(a[0])
				del a[0]
				continue
		if len(b) > 0:
			if b[0] == 0:
				k += 1
				ans.append(b[0])
				del b[0]
				continue
		if len(a) > 0:
			if a[0] <= k:
				ans.append(a[0])
				del a[0]
				continue
		if len(b) > 0:
			if b[0] <= k:
				ans.append(b[0])
				del b[0]
				continue
	if len(ans) == n + m:
		ans = [str(i) for i in ans]
		print(' '.join(ans))
	else:
		print(-1)


def answer(a, b, k):
	i = 0
	j = 0
	c = []
	f = True
	while i < len(a) or j < len(b):
		if i < len(a) and a[i] == 0:
			c.append(a[i])
			i += 1
			k += 1
		elif i < len(a) and a[i] <= k:
			c.append(a[i])
			i += 1
		elif j < len(b) and b[j] == 0:
			c.append(b[j])
			j += 1
			k += 1
		elif j < len(b) and b[j] <= k:
			c.append(b[j])
			j += 1
		else:
			f = False
			break
	if f:
		return c
	return [-1]
t = int(input())
for i in range(t):
	s = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = answer(a, b, k)
	if c[0] == -1:
		print(-1)
	else:
		print(*c)


t = int(input())
for _ in range(t):
	d = input()
	knm = list(map(int, input().split()))
	k = knm[0]
	n = knm[1]
	m = knm[2]
	an = list(map(int, input().split()))
	am = list(map(int, input().split()))
	b = [1 for _ in range(k)]
	c = []
	k = True
	for i in range(n + m):
		if len(an) > 0 and an[0] == 0:
			b.append(1)
			c.append(an[0])
			del an[0]
		elif len(am) > 0 and am[0] == 0:
			b.append(1)
			c.append(am[0])
			del am[0]
		elif (len(an) > 0 and an[0] > len(b)) and (len(am) > 0 and am[0] > len(b)):
			print(-1)
			k = False
			break
		elif len(an) > 0 and an[0] <= len(b):
			c.append(an[0])
			del an[0]
		elif len(am) > 0 and am[0] <= len(b):
			c.append(am[0])
			del am[0]
	if k:
		if len(c) == n + m:
			print(' '.join(list(map(str, c))))
		else:
			print(-1)


import math
t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	za = a.count(0)
	zeros = za + b.count(0)
	ma = max(a)
	g = max(ma, max(b))
	if k + zeros < g:
		print(-1)
	else:
		c = []
		ans = True
		(i, j) = (0, 0)
		while True:
			if i < n and j < m:
				if min(a[i], b[j]) > k:
					ans = False
					break
				if min(a[i], b[j]) == 0:
					k += 1
				if a[i] > b[j]:
					c.append(b[j])
					j += 1
				else:
					c.append(a[i])
					i += 1
			else:
				if i == n and j == m:
					break
				if i == n:
					if b[j] == 0:
						k += 1
					elif b[j] > k:
						ans = False
						break
					c.append(b[j])
					j += 1
				elif j == m:
					if a[i] == 0:
						k += 1
					elif a[i] > k:
						ans = False
						break
					c.append(a[i])
					i += 1
				else:
					break
		if ans:
			for x in c:
				print(x, end=' ')
			print()
		else:
			print(-1)


t = int(input())
q = input()
for q1 in range(t):
	(a, b, q) = map(int, input().split())
	lst = list(map(int, input().split()))
	lst1 = list(map(int, input().split()))
	lst2 = []
	i = 0
	j = 0
	while i < len(lst) and j < len(lst1):
		if lst[i] == 0:
			lst2.append(lst[i])
			a += 1
			i += 1
		elif lst1[j] == 0:
			a += 1
			lst2.append(lst1[j])
			j += 1
		elif lst[i] <= a:
			lst2.append(lst[i])
			i += 1
		elif lst1[j] <= a:
			lst2.append(lst1[j])
			j += 1
		else:
			break
	while i < len(lst):
		if lst[i] == 0:
			a += 1
			lst2.append(lst[i])
		elif a >= lst[i]:
			lst2.append(lst[i])
		else:
			break
		i += 1
	while j < len(lst1):
		if lst1[j] == 0:
			a += 1
			lst2.append(lst1[j])
		elif a >= lst1[j]:
			lst2.append(lst1[j])
		else:
			break
		j += 1
	if b + len(lst1) == len(lst2):
		print(*lst2)
	else:
		print(-1)
	if q1 != t - 1:
		q = input()


def solve(K, n, m, a, b):
	i = 0
	j = 0
	k = 0
	res = [0] * (n + m)
	while i < len(a) and j < len(b):
		if a[i] == 0 or a[i] <= K:
			res[k] = a[i]
			if a[i] == 0:
				K += 1
			k += 1
			i += 1
		elif b[j] == 0 or b[j] <= K:
			res[k] = b[j]
			if b[j] == 0:
				K += 1
			k += 1
			j += 1
		else:
			return -1
	while i < len(a):
		if a[i] == 0 or a[i] <= K:
			res[k] = a[i]
			if a[i] == 0:
				K += 1
			k += 1
			i += 1
		else:
			return -1
	while j < len(b):
		if b[j] == 0 or b[j] <= K:
			res[k] = b[j]
			if b[j] == 0:
				K += 1
			k += 1
			j += 1
		else:
			return -1
	return ' '.join(map(str, res))
t = int(input())
for i in range(t):
	input()
	(K, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(K, n, m, a, b))


import sys
from math import cos, pi, ceil, pi, tan, floor, gcd, sqrt, log2, factorial, log10
from collections import Counter
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase
from statistics import mean, median, mode
alpha = ascii_lowercase
beta = ascii_uppercase

def nextPowerOf2(n):
	p = 1
	if n and (not n & n - 1):
		return n
	while p < n:
		p <<= 1
	return p

def get_Divisors(n):
	arr = []
	i = 1
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				arr.append(i)
			else:
				arr.append(i)
				arr.append(n // i)
		i = i + 1
	return arr

def isprime(n):
	if n == 1:
		return 0
	i = 2
	while i * i <= n:
		if n % i == 0:
			return 0
		i += 1
	return 1

def Sieve(n):
	prime = [True for i in range(n + 1)]
	prime[0] = False
	prime[1] = False
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

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 main():
	for ttt in range(int(input())):
		s = input().strip()
		(k, n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		ap = 0
		bp = 0
		res = [i for i in range(1, k + 1)]
		ans = []
		flag = 0
		while ap < n or bp < m:
			if ap < n and a[ap] == 0:
				k += 1
				ans.append(a[ap])
				ap += 1
				res.append(k)
			elif bp < m and b[bp] == 0:
				k += 1
				res.append(k)
				ans.append(b[bp])
				bp += 1
			elif ap < n and a[ap] > 0 and (a[ap] in res):
				ans.append(a[ap])
				ap += 1
			elif bp < m and b[bp] > 0 and (b[bp] in res):
				ans.append(b[bp])
				bp += 1
			else:
				print(-1)
				flag = 1
				break
		if flag == 0:
			for i in range(ap, n):
				ans.append(a[i])
			for i in range(bp, m):
				ans.append(b[i])
			print(*ans)
main()


def pair_programming(n, a, b):
	res = []
	(i, j) = (0, 0)
	num = n
	while i < len(a) and j < len(b):
		if a[i] == 0 and b[j] == 0:
			res.extend([0, 0])
			i += 1
			j += 1
			num += 2
		elif a[i] == 0:
			res.append(0)
			num += 1
			i += 1
		elif b[j] == 0:
			res.append(0)
			num += 1
			j += 1
		elif a[i] < b[j]:
			if a[i] <= num:
				res.append(a[i])
				i += 1
			else:
				return None
		elif b[j] <= num:
			res.append(b[j])
			j += 1
		else:
			return None
	(idx, arr) = (None, None)
	if i == len(a):
		idx = j
		arr = b
	else:
		idx = i
		arr = a
	for i in range(idx, len(arr)):
		if arr[i] == 0:
			res.append(0)
			num += 1
		elif arr[i] <= num:
			res.append(arr[i])
		else:
			return None
	return res
N = int(input())
for _ in range(N):
	input()
	k = [int(s) for s in input().split()]
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	res = pair_programming(k[0], a, b)
	if res:
		print(*res)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	polycarp = list(map(int, input().split()))
	monocarp = list(map(int, input().split()))
	actions = []
	a = 0
	b = 0
	while a < n or b < m:
		if a < n and b < m:
			if polycarp[a] == 0:
				actions.append(0)
				k += 1
				a += 1
				continue
			if monocarp[b] == 0:
				actions.append(0)
				k += 1
				b += 1
				continue
			if polycarp[a] <= k:
				actions.append(polycarp[a])
				a += 1
				continue
			if monocarp[b] <= k:
				actions.append(monocarp[b])
				b += 1
				continue
			if polycarp[a] > k and monocarp[b] > k:
				actions = [-1]
				break
			break
		elif a < n:
			if polycarp[a] == 0:
				k += 1
				a += 1
				actions.append(0)
			elif polycarp[a] <= k:
				actions.append(polycarp[a])
				a += 1
			else:
				actions = [-1]
				break
		elif b < m:
			if monocarp[b] == 0:
				actions.append(0)
				k += 1
				b += 1
			elif monocarp[b] <= k:
				actions.append(monocarp[b])
				b += 1
			else:
				actions = [-1]
				break
		else:
			break
	print(' '.join(map(str, actions)))


t = int(input())
for i in range(t):
	p = 0
	q = 0
	x = []
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(n + m):
		w = 0
		if p < n:
			if a[p] == 0:
				k += 1
			if a[p] < k + 1:
				x.append(str(a[p]))
				p += 1
				w = 1
		if w == 0:
			if q < m:
				if b[q] == 0:
					k += 1
				if b[q] < k + 1:
					x.append(str(b[q]))
					q += 1
					w = 1
		if w == 0:
			x = ['-1']
			break
	print(' '.join(x))


t = int(input())
for i in range(t):
	empty = input()
	(k, n, m) = (int(i) for i in input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = ''
	mem = 0
	glf = True
	i = 0
	while i < n:
		if a[i] == 0:
			s += '0 '
			k += 1
		elif a[i] <= k:
			s += str(a[i]) + ' '
		elif mem != m:
			i -= 1
			flag = False
			for j in range(mem, m):
				if b[j] == 0:
					s += '0 '
					k += 1
					mem += 1
					break
				elif b[j] <= k:
					s += str(b[j]) + ' '
					mem += 1
					break
				else:
					flag = True
					break
			if flag:
				glf = False
				print(-1)
				break
		else:
			glf = False
			print('-1')
			break
		i += 1
	if glf:
		for j in range(mem, m):
			if b[j] == 0:
				s += '0 '
				k += 1
			elif b[j] <= k:
				s += str(b[j]) + ' '
			else:
				glf = False
				print('-1')
				break
	if glf:
		print(s[:len(s) - 1])


from collections import defaultdict

def fun(k, n, m, a, b):
	ans = []
	(i, j) = (0, 0)
	while i < n and j < m:
		if a[i] == 0:
			i += 1
			k += 1
			ans.append(0)
		elif b[j] == 0:
			j += 1
			k += 1
			ans.append(0)
		else:
			if k < a[i] and k < b[j]:
				return -1
			if k < a[i]:
				ans.append(b[j])
				j += 1
			elif k < b[j]:
				ans.append(a[i])
				i += 1
			elif a[i] < b[j]:
				ans.append(a[i])
				i += 1
			else:
				ans.append(b[j])
				j += 1
	while i < n:
		if a[i] == 0:
			k += 1
			ans.append(0)
		elif a[i] > k:
			return -1
		else:
			ans.append(a[i])
		i += 1
	while j < m:
		if b[j] == 0:
			k += 1
			ans.append(0)
		elif b[j] > k:
			return -1
		else:
			ans.append(b[j])
		j += 1
	return ans
tc = int(input())
for _ in range(tc):
	space = input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = fun(k, n, m, a, b)
	if ans == -1:
		print(-1)
	else:
		print(*ans)


for _ in range(int(input())):
	input()
	code = [0 for _ in range(301)]
	(k, _, _) = [int(i) for i in input().split()]
	mono = [int(i) for i in input().split()]
	poly = [int(i) for i in input().split()]
	ret = []
	(m, p) = (0, 0)
	while len(ret) != len(mono) + len(poly):
		if p < len(poly):
			pp = poly[p]
		else:
			pp = -999
		if m < len(mono):
			mm = mono[m]
		else:
			mm = -999
		if mm == 0:
			m += 1
			k += 1
			ret.append('0')
		elif pp == 0:
			p += 1
			k += 1
			ret.append('0')
		elif mm > 0 and mm <= k:
			code[mm] = 1
			m += 1
			ret.append(str(mm))
		elif pp > 0 and pp <= k:
			code[pp] = 1
			p += 1
			ret.append(str(pp))
		else:
			print('-1')
			break
	else:
		print(' '.join(ret))


def ger_res(k, n, m, arr_n, arr_m):
	res = []
	(i, j) = (0, 0)
	while i < n and j < m:
		if arr_n[i] <= k:
			if arr_n[i] == 0:
				k += 1
			res.append(arr_n[i])
			i += 1
			continue
		if arr_m[j] <= k:
			if arr_m[j] == 0:
				k += 1
			res.append(arr_m[j])
			j += 1
			continue
		if arr_n[i] > k and arr_m[j] > k:
			return [-1]
	while i < n:
		if arr_n[i] <= k:
			if arr_n[i] == 0:
				k += 1
			res.append(arr_n[i])
			i += 1
		else:
			return [-1]
	while j < m:
		if arr_m[j] <= k:
			if arr_m[j] == 0:
				k += 1
			res.append(arr_m[j])
			j += 1
		else:
			return [-1]
	return res
n_tests = int(input())
for _ in range(n_tests):
	input()
	(k, n, m) = map(int, input().split())
	arr_n = list(map(int, input().split()))
	arr_m = list(map(int, input().split()))
	print(*ger_res(k, n, m, arr_n, arr_m))


def process(A, B, k):
	answer = []
	i = 0
	j = 0
	n = len(A)
	m = len(B)
	curr = k
	while i < n or j < m:
		if i == n and B[j] <= curr:
			answer.append(B[j])
			if B[j] == 0:
				curr += 1
			j += 1
		elif i == n:
			return [False, []]
		elif j == m and A[i] <= curr:
			answer.append(A[i])
			if A[i] == 0:
				curr += 1
			i += 1
		elif j == m:
			return [False, []]
		elif A[i] == 0:
			answer.append(A[i])
			curr += 1
			i += 1
		elif B[j] == 0:
			answer.append(B[j])
			curr += 1
			j += 1
		elif A[i] <= curr:
			answer.append(A[i])
			i += 1
		elif B[j] <= curr:
			answer.append(B[j])
			j += 1
		else:
			return [False, []]
	return [True, answer]
t = int(input())
for i in range(t):
	input()
	(k, n, m) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	(a1, a2) = process(A, B, k)
	if a1:
		print(' '.join(map(str, a2)))
	else:
		print(-1)


for _ in range(int(input())):
	n = input()
	(k, n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	i = 0
	j = 0
	ans = []
	while True:
		if i < n and x[i] <= k:
			if x[i] == 0:
				k += 1
			ans.append(x[i])
			i += 1
		elif j < m and y[j] <= k:
			if y[j] == 0:
				k += 1
			ans.append(y[j])
			j += 1
		else:
			break
	if i < n or j < m:
		ans = [-1]
	for i in ans:
		print(i, end=' ')


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

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

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

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

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

def myceil(x, y):
	return (x + y - 1) // y

def check(arr, n, k):
	for i in range(n):
		if arr[i] == 0:
			k += 1
		if arr[i] > k:
			return False
	return True

def Solution(a, b, k, n, m):
	res = []
	i = 0
	j = 0
	while i < n and j < m:
		if a[i] < b[j]:
			res.append(a[i])
			i += 1
		else:
			res.append(b[j])
			j += 1
	while i < n:
		res.append(a[i])
		i += 1
	while j < m:
		res.append(b[j])
		j += 1
	if check(res, n + m, k):
		print(*res)
	else:
		print(-1)

def main():
	for _ in range(get_int()):
		input()
		(k, n, m) = get_ints_in_variables()
		a = get_ints_in_list()
		b = get_ints_in_list()
		Solution(a, b, k, n, m)
main()


T = int(input())
for _ in range(T):
	s = input()
	(k, n, m) = input().split()
	k = int(k)
	n = int(n)
	m = int(m)
	a = input().split()
	a = list(map(int, a))
	b = input().split()
	b = list(map(int, b))
	p1 = 0
	p2 = 0
	temp = 0
	ans = []
	flag = 0
	while p2 < m and p1 < n:
		temp = 0
		if a[p1] == 0:
			k += 1
			temp = 0
			ans.append(a[p1])
			temp = 0
			p1 += 1
		elif b[p2] == 0:
			temp = 0
			k += 1
			ans.append(b[p2])
			temp = 0
			p2 += 1
		elif a[p1] > k and b[p2] > k:
			temp = 0
			print(-1)
			flag = 1
			break
		elif a[p1] > k:
			temp = 0
			ans.append(b[p2])
			p2 += 1
			temp = 0
		else:
			ans.append(a[p1])
			temp = 0
			p1 += 1
	if flag == 1:
		continue
	while p1 < n:
		temp = 0
		if a[p1] == 0:
			ans.append(0)
			temp = 0
			k += 1
			p1 += 1
			temp = 0
		elif a[p1] <= k:
			ans.append(a[p1])
			temp = 0
			p1 += 1
		else:
			temp = 0
			flag = 1
			print(-1)
			break
	if flag == 1:
		continue
	while p2 < m:
		temp = 0
		if b[p2] == 0:
			ans.append(b[p2])
			temp = 0
			k += 1
			p2 += 1
			temp = 0
		elif b[p2] <= k:
			ans.append(b[p2])
			p2 += 1
			temp = 0
		else:
			temp = 0
			flag = 1
			print(-1)
			break
	if flag == 1:
		continue
	print(*ans)


def main():
	trials = int(input())
	for t in range(trials):
		input()
		(k, n, m) = [int(num) for num in input().split(' ')]
		nc = [int(num) for num in input().split(' ')]
		mc = [int(num) for num in input().split(' ')]
		order = list()
		ni = 0
		mi = 0
		while len(order) < m + n:
			if mi < m and mc[mi] == 0:
				order.append(0)
				mi += 1
				continue
			if ni < n and nc[ni] == 0:
				order.append(0)
				ni += 1
				continue
			if mi == m:
				order.append(nc[ni])
				ni += 1
				continue
			if ni == n or mc[mi] < nc[ni]:
				order.append(mc[mi])
				mi += 1
				continue
			if mi == m or nc[ni] <= mc[mi]:
				order.append(nc[ni])
				ni += 1
				continue
		lines = k
		fail = False
		for num in order:
			if num == 0:
				lines += 1
			elif num > lines:
				fail = True
				break
		if fail:
			print('-1')
		else:
			print(' '.join([str(num) for num in order]))
main()


import sys, math
sys.setrecursionlimit(10 ** 6)
mod = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def li():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	input()
	(K, N, M) = li()
	A = li()
	B = li()
	adx = 0
	bdx = 0
	ans = []
	flag = False
	while adx + bdx <= N + M:
		if adx == N and bdx == M:
			break
		if adx < N:
			a = A[adx]
		else:
			a = 10 ** 10
		if bdx < M:
			b = B[bdx]
		else:
			b = 10 ** 10
		if a == 0:
			adx += 1
			K += 1
			ans.append(a)
			continue
		elif b == 0:
			bdx += 1
			K += 1
			ans.append(b)
			continue
		elif a <= K:
			adx += 1
			ans.append(a)
		elif b <= K:
			bdx += 1
			ans.append(b)
		else:
			print(-1)
			flag = True
			break
	if flag:
		continue
	print(*ans)


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


for _ in range(int(input())):
	x = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(i, j) = (0, 0)
	ans = [0] * (n + m)
	for idx in range(n + m):
		if i == n:
			ans[idx] = b[j]
			j += 1
		elif j == m:
			ans[idx] = a[i]
			i += 1
		elif a[i] < b[j]:
			ans[idx] = a[i]
			i += 1
		else:
			ans[idx] = b[j]
			j += 1
	for i in ans:
		if i > k:
			ans = [-1]
			break
		if i == 0:
			k += 1
	print(*ans)


for _ in range(int(input())):
	waste = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	lim = 700
	flag = 0
	ans = []
	i = 0
	j = 0
	while i < len(a) or j < len(b):
		while i < len(a) and a[i] <= k:
			if a[i] == 0:
				k += 1
			ans.append(a[i])
			i += 1
		while j < len(b) and b[j] <= k:
			if b[j] == 0:
				k += 1
			ans.append(b[j])
			j += 1
		lim -= 1
		if lim == 0:
			flag = 1
			break
	print(*ans) if flag == 0 else print(-1)


import math
import os
import sys
from math import ceil, floor, sqrt, gcd, factorial
from io import BytesIO, IOBase
from collections import Counter
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 prog_name():
	input()
	(lines, n, m) = map(int, input().split())
	mono = list(map(int, input().split()))
	poly = list(map(int, input().split()))
	final = []
	mo = po = 0
	flag = True
	while (mo < n or po < m) and flag == True:
		if mo < n:
			if mono[mo] == 0:
				final.append(mono[mo])
				mo += 1
				lines += 1
			elif mono[mo] > 0:
				if mono[mo] <= lines:
					final.append(mono[mo])
					mo += 1
				elif po < m:
					if poly[po] == 0:
						final.append(poly[po])
						po += 1
						lines += 1
					elif poly[po] > 0:
						if poly[po] <= lines:
							final.append(poly[po])
							po += 1
						else:
							flag = False
							break
				else:
					flag = False
					break
		else:
			while po < m:
				if poly[po] == 0:
					final.append(poly[po])
					po += 1
					lines += 1
				elif poly[po] > 0:
					if poly[po] <= lines:
						final.append(poly[po])
						po += 1
					else:
						flag = False
						break
	if flag == False:
		print(-1)
	else:
		print(*final)

def main():
	T = int(input())
	for unique in range(T):
		prog_name()
main()


from collections import defaultdict
import sys, io, os
INP = sys.stdin.readline
inp = lambda : [*map(int, INP().encode().split())]
sinp = lambda : [*map(str, INP().split())]
out = sys.stdout.write

def main():
	for _ in range(inp()[0]):
		d = inp()
		(k, n, m) = inp()
		l = inp()
		p = inp()
		i = j = 0
		ans = []
		check = 1
		while i < n and j < m:
			if l[i] == 0:
				ans.append(0)
				k += 1
				i += 1
			elif p[j] == 0:
				ans.append(0)
				k += 1
				j += 1
			elif l[i] >= p[j] and p[j] <= k:
				ans.append(p[j])
				j += 1
			elif l[i] <= p[j] and l[i] <= k:
				ans.append(l[i])
				i += 1
			else:
				check = 0
				break
			if not check:
				break
		if check:
			while i < n:
				if l[i] == 0:
					ans.append(0)
					k += 1
					i += 1
				elif l[i] <= k:
					ans.append(l[i])
					i += 1
				else:
					check = 0
					break
			while j < m:
				if p[j] == 0:
					ans.append(0)
					k += 1
					j += 1
				elif p[j] <= k:
					ans.append(p[j])
					j += 1
				else:
					check = 0
					break
			if check:
				print(*ans)
			else:
				print(-1)
		else:
			print(-1)

def SumOfExpOfFactors(a):
	fac = 0
	lis = SortedList()
	if not a & 1:
		lis.add(2)
	while not a & 1:
		a >>= 1
		fac += 1
	for i in range(3, int(a ** 0.5) + 1, 2):
		if not a % i:
			lis.add(i)
		while not a % i:
			a //= i
			fac += 1
	if a != 1:
		lis.add(a)
		fac += 1
	return (fac, lis)
div = [0] * 1000001

def NumOfDivisors(n):
	for i in range(1, n + 1):
		for j in range(i, n + 1, i):
			div[j] += 1

def primes1(n):
	sieve = [True] * (n // 2)
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i // 2]:
			sieve[i * i // 2::i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [2 * i + 1 for i in range(1, n // 2) if sieve[i]]

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

class Graph:

	def __init__(self):
		self.Graph = defaultdict(list)

	def addEdge(self, u, v):
		self.Graph[u].append(v)
		self.Graph[v].append(u)

	def DFSUtil(self, v, visited):
		visited.add(v)
		for neighbour in self.Graph[v]:
			if neighbour not in visited:
				self.DFSUtil(neighbour, visited)

	def DFS(self, v):
		visited = set()
		self.DFSUtil(v, visited)

	def BFS(self, s):
		visited = set()
		queue = []
		queue.append(s)
		visited.add(s)
		while queue:
			s = queue.pop(0)
			for i in self.Graph[s]:
				if i not in visited:
					queue.append(i)
					visited.add(i)

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))
main()


from collections import deque
import sys
input = sys.stdin.readline
T = int(input())
input()
for _ in range(T):
	(k, n, m) = map(int, input().split())
	a = deque(map(int, input().split()))
	b = deque(map(int, input().split()))
	answer = []
	flg = True
	for _ in range(n + m):
		if len(a) > 0 and a[0] <= k:
			t = a.popleft()
			answer.append(t)
			if t == 0:
				k += 1
		elif len(b) > 0 and b[0] <= k:
			t = b.popleft()
			answer.append(t)
			if t == 0:
				k += 1
		else:
			flg = False
			break
	if flg:
		print(' '.join(map(str, answer)))
	else:
		print(-1)
	input()


t = int(input())
for _ in range(t):
	l = input()
	(k, n, m) = map(int, input().split())
	bunchn = []
	bunchn.extend(map(int, input().split()))
	bunchm = []
	bunchm.extend(map(int, input().split()))
	f = True
	seq = ''
	indn = indm = 0
	for i in range(0, n + m):
		if indn < n and bunchn[indn] == 0:
			k += 1
			seq += '0 '
			indn += 1
		elif indm < m and bunchm[indm] == 0:
			k += 1
			seq += '0 '
			indm += 1
		elif indn < n and bunchn[indn] <= k:
			seq += str(bunchn[indn]) + ' '
			indn += 1
		elif indm < m and bunchm[indm] <= k:
			seq += str(bunchm[indm]) + ' '
			indm += 1
		else:
			f = False
			break
	if not f:
		print(-1)
	else:
		print(seq.strip())


for i in range(int(input())):
	noth = input()
	ans = []
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	m = 0
	p = 0
	while m != len(a) or p != len(b):
		if m < len(a) and a[m] <= k:
			for j in range(m, len(a)):
				if a[j] == 0:
					k += 1
					ans.append(a[j])
					m += 1
				elif a[j] <= k:
					ans.append(a[j])
					m += 1
				else:
					break
		elif p < len(b) and b[p] <= k:
			for j in range(p, len(b)):
				if b[j] == 0:
					k += 1
					ans.append(b[j])
					p += 1
				elif b[j] <= k:
					ans.append(b[j])
					p += 1
				else:
					break
		else:
			ans = -1
			m = len(a)
			p = len(b)
	if ans == -1:
		print(ans)
	else:
		print(*ans)


def check_pair_programming(num_lines):
	num_lines = int(num_lines)
	for i in range(num_lines):
		emptyline = input()
		int_line = input().split()
		(k, n, m) = (int(int_line[0]), int(int_line[1]), int(int_line[2]))
		list1 = input().split()
		list1 = [int(x) for x in list1]
		list2 = input().split()
		list2 = [int(x) for x in list2]
		res = restore_order(k, list1, list2)
		print(res)

def restore_order(k, seq1, seq2):
	i = 0
	j = 0
	final_seq = []
	prev_length = len(final_seq)
	while i < len(seq1) or j < len(seq2):
		new_length = prev_length
		if i < len(seq1) and seq1[i] == 0:
			final_seq.append(str(seq1[i]))
			new_length += 1
			k += 1
			i += 1
		elif i < len(seq1) and seq1[i] <= k:
			final_seq.append(str(seq1[i]))
			new_length += 1
			i += 1
		if j < len(seq2) and seq2[j] == 0:
			final_seq.append(str(seq2[j]))
			new_length += 1
			k += 1
			j += 1
		elif j < len(seq2) and seq2[j] <= k:
			final_seq.append(str(seq2[j]))
			new_length += 1
			j += 1
		if prev_length == new_length:
			return -1
		prev_length = new_length
	return ' '.join(final_seq)
num_lines = input()
check_pair_programming(num_lines)


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


import sys

def restore(n, m, k):
	goodSeq = []
	nIdx = 0
	mIdx = 0
	while nIdx < len(n) or mIdx < len(m):
		if mIdx < len(m) and m[mIdx] == 0:
			k += 1
			goodSeq.append(m[mIdx])
			mIdx += 1
		elif nIdx < len(n) and n[nIdx] == 0:
			k += 1
			goodSeq.append(n[nIdx])
			nIdx += 1
		elif mIdx < len(m) and m[mIdx] <= k:
			goodSeq.append(m[mIdx])
			mIdx += 1
		elif nIdx < len(n) and n[nIdx] <= k:
			goodSeq.append(n[nIdx])
			nIdx += 1
		else:
			return ['-1']
	return goodSeq
casos = int(sys.stdin.readline().rstrip('\n'))
for i in range(casos):
	blank = sys.stdin.readline().rstrip('\n').split(' ')
	(k, nNum, mNum) = sys.stdin.readline().rstrip('\n').split(' ')
	n = sys.stdin.readline().rstrip('\n').split(' ')
	n = list(map(int, n))
	m = sys.stdin.readline().rstrip('\n').split(' ')
	m = list(map(int, m))
	k = int(k)
	ans = restore(n, m, k)
	ans = list(map(str, ans))
	sys.stdout.write(' '.join(ans) + '\n')


t = int(input())
for i in range(t):
	shit = input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = []
	ress = 1
	for aa in a:
		if ress == -1:
			break
		elif aa == 0:
			k += 1
			res.append(aa)
		elif aa > k:
			while k < aa:
				if len(b) == 0:
					ress = -1
					break
				elif b[0] == 0:
					k += 1
					res.append(b.pop(0))
				elif b[0] > k:
					ress = -1
					break
				else:
					res.append(b.pop(0))
			res.append(aa)
		else:
			res.append(aa)
			continue
	if ress == -1:
		print(ress)
	else:
		for bb in b:
			if ress == -1:
				break
			elif bb == 0:
				k += 1
				res.append(bb)
			elif bb > k:
				ress = -1
			else:
				res.append(bb)
			continue
		if ress == -1:
			print(ress)
		else:
			print(*res)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	g = sys.stdin.readline()
	(k, n, m) = map(lambda x: int(x), sys.stdin.readline().split())
	n_a = list(map(lambda x: int(x), sys.stdin.readline().split()))
	m_a = list(map(lambda x: int(x), sys.stdin.readline().split()))
	i = 0
	j = 0
	res = []
	while i < n or j < m:
		if i < n:
			if n_a[i] > k:
				if j >= m or m_a[j] > k:
					res.append(-1)
					break
				else:
					if m_a[j] == 0:
						k += 1
					res.append(m_a[j])
					j += 1
			else:
				if n_a[i] == 0:
					k += 1
				res.append(n_a[i])
				i += 1
		elif m_a[j] > k:
			res.append(-1)
			break
		else:
			if m_a[j] == 0:
				k += 1
			res.append(m_a[j])
			j += 1
	if res[-1] == -1:
		print(-1)
	else:
		print(' '.join(map(lambda x: str(x), res)))


for _ in range(int(input())):
	input()
	(k, n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ans = True
	b_be = True
	arr = []
	i = j = 0
	do = True
	while True:
		if i < len(a) and a[i] == 0:
			arr.append(0)
			k += 1
			i += 1
			b_be = True
			continue
		elif i < len(a) and a[i] <= k:
			arr.append(a[i])
			i += 1
			b_be = True
			continue
		else:
			if len(a) == i and len(b) == j:
				ans = True
				break
			if not b_be:
				ans = False
				break
			while True:
				if j < len(b) and b[j] == 0:
					arr.append(0)
					k += 1
					j += 1
					continue
				elif j < len(b) and b[j] <= k:
					arr.append(b[j])
					j += 1
					continue
				else:
					b_be = False
					break
			continue
	if ans:
		print(*arr)
	else:
		print(-1)


t = int(input())
for i in range(t):
	a = input()
	(k, n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	now = k
	i = 0
	j = 0
	ans = []
	while i < n or j < m:
		if i != n:
			if a[i] == 0:
				k += 1
				ans.append(0)
				i += 1
				continue
			elif k >= a[i]:
				ans.append(a[i])
				i += 1
				continue
		if j != m:
			if b[j] == 0:
				k += 1
				ans.append(0)
				j += 1
				continue
			elif k >= b[j]:
				ans.append(b[j])
				j += 1
				continue
		break
	if len(ans) < n + m:
		print(-1)
	else:
		for i in range(n + m):
			print(ans[i], end=' ')
		print()


for _ in range(int(input())):
	s = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	j = 0
	f = 0
	ans = []
	while i < n or j < m:
		if i == n:
			if b[j] > k:
				print(-1)
				f = 1
				break
			if b[j] == 0:
				k += 1
			ans.append(b[j])
			j += 1
		elif j == m:
			if a[i] > k:
				print(-1)
				f = 1
				break
			if a[i] == 0:
				k += 1
			ans.append(a[i])
			i += 1
		elif a[i] == 0:
			ans.append(a[i])
			i += 1
			k += 1
		elif b[j] == 0:
			ans.append(b[j])
			j += 1
			k += 1
		elif a[i] <= k:
			ans.append(a[i])
			i += 1
		elif b[j] <= k:
			ans.append(b[j])
			j += 1
		else:
			print(-1)
			f = 1
			break
	if f:
		continue
	print(*ans)


for _ in range(int(input())):
	s = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l1 = 0
	l2 = 0
	ans = []
	flag = 0
	while l1 < n and l2 < m:
		if a[l1] <= k and b[l2] <= k:
			if a[l1] == 0:
				ans.append(a[l1])
				k = k + 1
				l1 = l1 + 1
			else:
				ans.append(a[l1])
				l1 = l1 + 1
		elif a[l1] <= k:
			if a[l1] == 0:
				ans.append(a[l1])
				k = k + 1
				l1 = l1 + 1
			else:
				ans.append(a[l1])
				l1 = l1 + 1
		elif b[l2] <= k:
			if b[l2] == 0:
				ans.append(b[l2])
				k = k + 1
				l2 = l2 + 1
			else:
				ans.append(b[l2])
				l2 = l2 + 1
		else:
			flag = 1
			break
	if flag == 1:
		print(-1)
	else:
		while l1 < n:
			if a[l1] == 0:
				k = k + 1
				ans.append(a[l1])
				l1 = l1 + 1
			elif a[l1] <= k:
				ans.append(a[l1])
				l1 = l1 + 1
			else:
				print(-1)
				flag = 1
				break
		while l2 < m:
			if b[l2] == 0:
				k = k + 1
				ans.append(b[l2])
				l2 = l2 + 1
			elif b[l2] <= k:
				ans.append(b[l2])
				l2 = l2 + 1
			else:
				print(-1)
				flag = 1
				break
		if flag == 0:
			print(*ans)


for _ in range(int(input())):
	q = input()
	(k, n, m) = [int(a) for a in input().split()]
	ar = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:m]
	t = ar.count(0)
	h = b.count(0)
	p = max(max(ar), max(b))
	if k + t + h < p:
		print(-1)
	else:
		i = 0
		j = 0
		d = k
		w = 0
		c = []
		while i < n and j < m:
			if ar[i] < b[j]:
				if ar[i] == 0:
					d = d + 1
				c.append(ar[i])
				i = i + 1
			else:
				if b[j] == 0:
					d = d + 1
				c.append(b[j])
				j = j + 1
			if c[-1] > d:
				w = 1
				break
		while i < n:
			if ar[i] == 0:
				d = d + 1
			c.append(ar[i])
			i = i + 1
			if c[-1] > d:
				w = 1
				break
		while j < m:
			if b[j] == 0:
				d = d + 1
			c.append(b[j])
			j = j + 1
			if c[-1] > d:
				w = 1
				break
		if w:
			print(-1)
		else:
			print(*c)


from bisect import bisect_left
for t in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(ai, bi, res) = (0, 0, [])
	good = True
	while ai < len(a) and bi < len(b):
		if a[ai] == 0:
			res.append('0')
			ai += 1
			k += 1
		elif b[bi] == 0:
			res.append('0')
			bi += 1
			k += 1
		elif a[ai] < b[bi]:
			if a[ai] <= k:
				res.append(str(a[ai]))
				ai += 1
			else:
				good = False
				break
		elif b[bi] <= k:
			res.append(str(b[bi]))
			bi += 1
		else:
			good = False
			break
	while good and ai < len(a):
		if a[ai] == 0:
			res.append('0')
			ai += 1
			k += 1
		elif a[ai] <= k:
			res.append(str(a[ai]))
			ai += 1
		else:
			good = False
			break
	while good and bi < len(b):
		if b[bi] == 0:
			res.append('0')
			bi += 1
			k += 1
		elif b[bi] <= k:
			res.append(str(b[bi]))
			bi += 1
		else:
			good = False
			break
	if good:
		print(' '.join(res))
	else:
		print(-1)


def solve():
	res = []
	s = input()
	(lines_in_file, n, m) = [int(e) for e in input().split()]
	(f, sec) = (0, 0)
	first = [int(e) for e in input().split()]
	second = [int(e) for e in input().split()]
	for i in range(n + m):
		if f < n and first[f] == 0:
			lines_in_file += 1
			res.append(first[f])
			f += 1
		elif sec < m and second[sec] == 0:
			lines_in_file += 1
			res.append(second[sec])
			sec += 1
		elif f < n and first[f] > 0 and (first[f] <= lines_in_file):
			res.append(first[f])
			f += 1
		elif sec < m and second[sec] > 0 and (second[sec] <= lines_in_file):
			res.append(second[sec])
			sec += 1
		else:
			return [-1]
	return res
cases = int(input())
while cases > 0:
	cases -= 1
	print(*solve())


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')
from types import GeneratorType

def bootstrap(f, stack=[]):

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

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	c = dict(Counter(l))
	return list(set(l))

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 sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

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

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

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

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def fun(l, index, k):
	for i in range(index, len(l)):
		if l[i] == 0:
			k += 1
			return [True, i + 1, 1]
		elif l[i] > k:
			return [False, 0, 0]
	return [True, len(l), 0]

def solve():
	aa = input()
	(k, n, m) = li()
	a = li()
	b = li()
	i = 0
	j = 0
	ans = []
	while i < len(a) and j < len(b):
		[pos, newi, ff] = fun(a, i, k)
		if pos == True:
			pi = i
			i = newi
			for kk in range(pi, newi):
				ans.append(a[kk])
			if i != len(a):
				k += ff
				continue
			else:
				k += ff
				break
		[pos, newj, ff] = fun(b, j, k)
		if pos == True:
			pi = j
			j = newj
			for kk in range(pi, newj):
				ans.append(b[kk])
			if j != len(b):
				k += ff
				continue
			else:
				k += ff
				break
		print(-1)
		return
	for jj in range(j, len(b)):
		ans.append(b[jj])
		if b[jj] == 0:
			k += 1
		elif b[jj] > k:
			print(-1)
			return
	for jj in range(i, len(a)):
		ans.append(a[jj])
		if a[jj] == 0:
			k += 1
		elif a[jj] > k:
			print(-1)
			return
	print(*ans)
t = 1
t = ii()
for _ in range(t):
	solve()


tc = int(input())
for _ in range(tc):
	input()
	(k, n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	(i, j, ans) = (0, 0, [])
	while i < n or j < m:
		if i < n and a[i] == 0:
			k += 1
			ans.append(a[i])
			i += 1
		elif j < m and b[j] == 0:
			k += 1
			ans.append(b[j])
			j += 1
		elif i < n and a[i] <= k:
			ans.append(a[i])
			i += 1
		elif j < m and b[j] <= k:
			ans.append(b[j])
			j += 1
		else:
			break
	if len(ans) == n + m:
		print(*ans)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	x = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = [0 for i in range(k)]
	i = j = 0
	flag = 1
	arr = []
	while i < n and j < m:
		try:
			if a[i] <= b[j]:
				arr.append(a[i])
				if a[i] == 0:
					ans.append(0)
				else:
					ans[a[i] - 1] = a[i]
				i += 1
			else:
				arr.append(b[j])
				if b[j] == 0:
					ans.append(0)
				else:
					ans[b[j] - 1] = b[j]
				j += 1
		except:
			flag = 0
			break
	while i < n:
		try:
			arr.append(a[i])
			if a[i] == 0:
				ans.append(0)
			else:
				ans[a[i] - 1] = a[i]
			i += 1
		except:
			flag = 0
			break
	while j < m:
		try:
			arr.append(b[j])
			if b[j] == 0:
				ans.append(0)
			else:
				ans[b[j] - 1] = b[j]
			j += 1
		except:
			flag = 0
			break
	if flag:
		print(*arr)
	else:
		print(-1)


def restore_history(initial_line_count, seq_a, seq_b):
	history = []
	cursors = [0, 0]
	current_cursor_index = 0
	switch_count = 0
	line_count = initial_line_count
	while len(history) < len(seq_a) + len(seq_b):
		seq = seq_a if current_cursor_index == 0 else seq_b
		if cursors[current_cursor_index] < len(seq):
			action = seq[cursors[current_cursor_index]]
			if action == 0 or action <= line_count:
				history.append(str(action))
				cursors[current_cursor_index] += 1
				if action == 0:
					line_count += 1
				switch_count = 0
			else:
				current_cursor_index = (current_cursor_index + 1) % 2
				switch_count += 1
		else:
			current_cursor_index = (current_cursor_index + 1) % 2
			switch_count += 1
		if switch_count > 1:
			return []
	return history
T = int(input())
import sys
while T:
	sys.stdin.readline()
	(k, n, m) = list(map(int, sys.stdin.readline().split()))
	seq_a = list(map(int, sys.stdin.readline().split()))
	seq_b = list(map(int, sys.stdin.readline().split()))
	history = restore_history(k, seq_a, seq_b)
	if history:
		print(' '.join(history))
	else:
		print(-1)
	T -= 1


import sys
t = int(input())
for T in range(t):
	empty = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	i = 0
	j = 0
	while i < n or j < m:
		if i == n:
			if b[j] == 0:
				k += 1
				c.append(b[j])
				j += 1
			elif b[j] <= k:
				c.append(b[j])
				j += 1
			else:
				c = -1
				break
		elif j == m:
			if a[i] == 0:
				k += 1
				c.append(a[i])
				i += 1
			elif a[i] <= k:
				c.append(a[i])
				i += 1
			else:
				c = -1
				break
		elif a[i] == 0:
			k += 1
			c.append(a[i])
			i += 1
		elif b[j] == 0:
			k += 1
			c.append(b[j])
			j += 1
		elif a[i] <= b[j]:
			if a[i] <= k:
				c.append(a[i])
				i += 1
			else:
				c = -1
				break
		elif b[j] < a[i]:
			if b[j] <= k:
				c.append(b[j])
				j += 1
			else:
				c = -1
				break
	if c == -1:
		print(c)
	else:
		print(*c)


import math

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

def stringlist():
	return input().split(' ')

def yes(t):
	if t:
		return 'YES'
	return 'NO'

def printjoin(l, str=False):
	if str:
		l = [str(i) for i in l]
	return ' '.join(l)

def power_of_two(n):
	b = bin(n)[2:]
	return int(b) == 10 ** (len(b) - 1)

def bit_count(n):
	return bin(n).count('1')

def solve():
	k = input()
	(k, n, m) = intlist()
	a = intlist()
	b = intlist()
	c = 0
	d = 0
	ans = []
	while c < n or d < m:
		if c < n:
			if a[c] == 0:
				ans.append(str(a[c]))
				c += 1
				k += 1
				continue
			elif a[c] <= k:
				ans.append(str(a[c]))
				c += 1
				continue
			elif d == m:
				return -1
		if d < m:
			if b[d] == 0:
				ans.append(str(b[d]))
				d += 1
				k += 1
				continue
			if b[d] <= k:
				ans.append(str(b[d]))
				d += 1
				continue
			else:
				return -1
	return printjoin(ans)
	return ''
t = input()
for tt in range(int(t)):
	print(solve())


import math

def solve():
	x = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	q = a.count(0) + b.count(0)
	index_a = 0
	index_b = 0
	ans = []
	while index_a + index_b < m + n:
		while index_a < n and a[index_a] == 0:
			ans.append(0)
			k += 1
			index_a += 1
		while index_b < m and b[index_b] == 0:
			ans.append(0)
			k += 1
			index_b += 1
		if index_a < n and index_b < m:
			if min(a[index_a], b[index_b]) > k:
				return '-1'
			if a[index_a] <= b[index_b]:
				ans.append(a[index_a])
				index_a += 1
			else:
				ans.append(b[index_b])
				index_b += 1
		elif index_a < n:
			if a[index_a] > k:
				return '-1'
			ans.append(a[index_a])
			index_a += 1
		elif index_b < m:
			if b[index_b] > k:
				return '-1'
			ans.append(b[index_b])
			index_b += 1
	return ' '.join(map(str, ans))
t = int(input())
while t > 0:
	t -= 1
	print(solve())


def solution(k, a, b):
	n = len(a)
	m = len(b)
	(i, j) = (0, 0)
	result = []
	for _ in range(m + n):
		if i < n and (a[i] <= k or a[i] == 0):
			if a[i] == 0:
				k += 1
			result.append(a[i])
			i += 1
		elif j < m and (b[j] <= k or b[j] == 0):
			if b[j] == 0:
				k += 1
			result.append(b[j])
			j += 1
		else:
			return [-1]
	return result
for _ in range(int(input())):
	_ = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(' '.join((str(x) for x in solution(k, a, b))))


for _ in range(int(input())):
	t = input()
	(k, n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l = []
	i = 0
	j = 0
	chk = 0
	while i < n or j < m:
		while i < n:
			f = 0
			if l1[i] != 0:
				if l1[i] <= k:
					l.append(l1[i])
					i += 1
					f = 1
					chk = 0
			elif l1[i] == 0:
				l.append(l1[i])
				k += 1
				f = 1
				i += 1
				chk = 0
			if f == 0:
				chk += 1
				break
		while j < m:
			f = 0
			if l2[j] != 0:
				if l2[j] <= k:
					l.append(l2[j])
					j += 1
					f = 1
					chk = 0
			elif l2[j] == 0:
				l.append(l2[j])
				k += 1
				f = 1
				j += 1
				chk = 0
			if f == 0:
				chk += 1
				break
		if chk > 4:
			break
	if chk > 4:
		print(-1)
	else:
		print(*l)


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


from collections import deque
for _ in range(int(input())):
	blank = input()
	(k, n, m) = map(int, input().split())
	a = deque(map(int, input().split()))
	b = deque(map(int, input().split()))
	ans = []
	fail = False
	while a and b:
		next_a = a[0]
		next_b = b[0]
		if next_a == 0:
			ans.append(0)
			k += 1
			a.popleft()
		elif next_b == 0:
			ans.append(0)
			k += 1
			b.popleft()
		elif next_a <= next_b:
			if next_a <= k:
				ans.append(next_a)
				a.popleft()
			else:
				fail = True
				break
		elif next_b <= k:
			ans.append(next_b)
			b.popleft()
		else:
			fail = True
			break
	else:
		while a:
			next_a = a[0]
			if next_a == 0:
				ans.append(0)
				k += 1
				a.popleft()
			elif next_a <= k:
				ans.append(next_a)
				a.popleft()
			else:
				fail = True
				break
		while b:
			next_b = b[0]
			if next_b == 0:
				ans.append(0)
				k += 1
				b.popleft()
			elif next_b <= k:
				ans.append(next_b)
				b.popleft()
			else:
				fail = True
				break
	if not fail:
		print(*ans)
	else:
		print(-1)


for _ in range(int(input())):
	temp = list(input())
	(k, n, m) = map(int, input().split())
	an = list(map(int, input().split()))
	am = list(map(int, input().split()))
	i = 0
	j = 0
	l = k
	sol = []
	f = 1
	while len(sol) != n + m:
		if i < n and an[i] == 0:
			sol.append(0)
			i += 1
			l += 1
		elif j < m and am[j] == 0:
			sol.append(0)
			j += 1
			l += 1
		elif i < n and an[i] <= l:
			sol.append(an[i])
			i += 1
		elif j < m and am[j] <= l:
			sol.append(am[j])
			j += 1
		else:
			f = 0
			break
	if f == 0:
		print(-1)
	else:
		print(*sol)


t = int(input())
for s in range(t):
	input()
	r = list(map(int, input().split()))
	n = r[1] + r[2]
	k = r[0]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	(p, q) = (0, 0)
	flag = 1
	for i in range(n):
		t = 0
		if p < r[1]:
			if a[p] == 0:
				c.append(a[p])
				p += 1
				k += 1
			elif a[p] <= k:
				c.append(a[p])
				p += 1
			else:
				t = 1
		else:
			t = 1
		if q < r[2] and t == 1:
			if b[q] == 0:
				c.append(b[q])
				k += 1
				q += 1
			elif b[q] <= k:
				c.append(b[q])
				q += 1
	if flag == 1 and len(c) == n:
		for i in c:
			print(i, end=' ')
		print()
	else:
		print(-1)


def Pairs(A, B):
	(i, j) = (0, 0)
	curr = k
	ans = []
	while i < len(A) and j < len(B):
		if A[i] <= B[j]:
			if A[i] == 0:
				curr += 1
			elif curr < A[i]:
				print(-1)
				return
			ans.append(A[i])
			i += 1
		else:
			if B[j] == 0:
				curr += 1
			elif curr < B[j]:
				print(-1)
				return
			ans.append(B[j])
			j += 1
	if i == len(A):
		while j < len(B):
			if B[j] == 0:
				curr += 1
			elif curr < B[j]:
				print(-1)
				return
			ans.append(B[j])
			j += 1
	else:
		while i < len(A):
			if A[i] == 0:
				curr += 1
			elif curr < A[i]:
				print(-1)
				return
			ans.append(A[i])
			i += 1
	print(*ans)
t = int(input())
for _ in range(t):
	s = input()
	(k, n, m) = map(int, input().split())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	Pairs(A, B)


def solve(k, n, m, arr1, arr2):
	res = []
	i = j = 0
	while i != n or j != m:
		if i != n and arr1[i] <= k:
			res.append(arr1[i])
			if arr1[i] == 0:
				k += 1
			i += 1
		elif j != m and arr2[j] <= k:
			res.append(arr2[j])
			if arr2[j] == 0:
				k += 1
			j += 1
		else:
			res = [-1]
			break
	return ' '.join(map(str, res))
t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	print(solve(k, n, m, arr1, arr2))


from itertools import combinations_with_replacement
import sys
from sys import stdin
import math
import bisect

def BinarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def iinput():
	return int(input())

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

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

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

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

def flinput():
	return list(map(int, stdin.readline().strip().split()))
for _ in range(iinput()):
	pp = input()
	(k, n, m) = minput()
	list1 = linput()
	list2 = linput()
	i = 0
	j = 0
	ll = []
	f = 0
	while i < n and j < m:
		if list1[i] == 0:
			ll.append(list1[i])
			k += 1
			i += 1
		elif list2[j] == 0:
			ll.append(list2[j])
			k += 1
			j += 1
		elif list1[i] <= list2[j]:
			if list1[i] > k:
				f = 1
				break
			else:
				ll.append(list1[i])
				i += 1
		elif list1[i] > list2[j]:
			if list2[j] > k:
				f = 1
				break
			else:
				ll.append(list2[j])
				j += 1
	while i < n:
		if list1[i] > k:
			f = 1
			break
		else:
			ll.append(list1[i])
			if list1[i] == 0:
				k += 1
			i += 1
	while j < m:
		if list2[j] > k:
			f = 1
			break
		else:
			ll.append(list2[j])
			if list2[j] == 0:
				k += 1
			j += 1
	if f == 0:
		print(*ll)
	else:
		print(-1)


for _ in range(int(input())):
	e = input()
	ans = []
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	lg = 0
	for i in range(n):
		if a[i] == 0:
			k += 1
			ans.append(0)
		elif a[i] > k:
			for f in range(lg, m):
				if b[f] == 0:
					k += 1
					ans.append(0)
					lg += 1
				elif b[f] > k:
					lg -= 1
					break
				else:
					ans.append(b[f])
					lg += 1
			if a[i] > k:
				ans = [-1]
				break
			else:
				ans.append(a[i])
				lg += 1
		else:
			ans.append(a[i])
	for i in range(lg, m):
		if b[i] == 0:
			k += 1
			ans.append(0)
			lg += 1
		elif b[i] > k:
			ans = [-1]
			break
		else:
			ans.append(b[i])
			lg += 1
	if ans[0] != -1:
		print(*ans)
	else:
		print(-1)


t = int(input())
for i in range(t):
	space = input()
	(k, n, m) = [int(v) for v in input().split()]
	w = [int(v) for v in input().split()][::-1]
	z = [int(v) for v in input().split()][::-1]
	res = []
	while n > 0 and m > 0:
		if w[-1] > k and z[-1] > k:
			print(-1)
			break
		elif w[-1] == 0:
			res.append(w.pop())
			n -= 1
			k += 1
		elif z[-1] == 0:
			res.append(z.pop())
			m -= 1
			k += 1
		elif w[-1] <= z[-1]:
			res.append(w.pop())
			n -= 1
		else:
			res.append(z.pop())
			m -= 1
	else:
		(iota, n) = (w + z, n + m)
		while n:
			if iota[-1] > k:
				print(-1)
				break
			elif iota[-1] == 0:
				k += 1
				n -= 1
				res.append(iota.pop())
			else:
				n -= 1
				res.append(iota.pop())
		else:
			print(' '.join([str(v) for v in res]))


import sys
MOD = 1000000007
no = lambda : print('NO')
yes = lambda : print('YES')
_1 = lambda : print(-1)
ari = lambda : [int(_) for _ in input().split()]
cin = lambda : int(input())
cis = lambda : input()
show = lambda x: print(x)
test_case = 1
test_case = int(input())

def ans():
	(lno, m, n) = ari()
	mono = ari()
	poly = ari()
	ans = []
	c = 0
	p = 0
	m1 = 0
	while m1 < m or p < n:
		if m1 < m and mono[m1] == 0:
			m1 += 1
			ans.append(0)
			lno += 1
		elif p < n and poly[p] == 0:
			lno += 1
			p += 1
			ans.append(0)
		elif p < n and poly[p] <= lno:
			ans.append(poly[p])
			p += 1
		elif m1 < m and mono[m1] <= lno:
			ans.append(mono[m1])
			m1 += 1
		else:
			_1()
			return
	print(*ans)
	return
for _ in range(test_case):
	gar = input().split()
	ans()


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left, bisect
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p = [0] * (n + m)
	f = 1
	(i, j) = (0, 0)
	c = 0
	while i < n and j < m:
		if a[i] == b[j]:
			if a[i] == 0:
				p[c] = a[i]
				i += 1
				c += 1
				k += 1
			elif a[i] <= k:
				p[c] = a[i]
				i += 1
				c += 1
			else:
				f = 0
				break
		elif a[i] <= k and b[j] <= k:
			if a[i] <= b[j]:
				p[c] = a[i]
				c += 1
				if a[i] == 0:
					k += 1
				i += 1
			else:
				p[c] = b[j]
				c += 1
				if b[j] == 0:
					k += 1
				j += 1
		elif a[i] <= k:
			p[c] = a[i]
			c += 1
			if a[i] == 0:
				k += 1
			i += 1
		elif b[j] <= k:
			p[c] = b[j]
			c += 1
			if b[j] == 0:
				k += 1
			j += 1
		else:
			f = 0
			break
	if f:
		while i < n:
			if a[i] <= k:
				p[c] = a[i]
				c += 1
				if a[i] == 0:
					k += 1
				i += 1
			else:
				f = 0
				break
		while j < m:
			if b[j] <= k:
				p[c] = b[j]
				c += 1
				if b[j] == 0:
					k += 1
				j += 1
			else:
				f = 0
				break
	if f:
		print(*p)
	else:
		print(-1)


import math

def getList(method=int):
	return list(map(method, input().split()))

def getInt():
	return int(input())

def solve():
	input()
	(k, n, m) = getList()
	a = getList()
	b = getList()
	pc = k
	(i, j) = (0, 0)
	seq = []
	printed = False
	for x in range(n + m):
		if i < n and a[i] == 0:
			i += 1
			pc += 1
			seq.append(0)
		elif j < m and b[j] == 0:
			j += 1
			pc += 1
			seq.append(0)
		elif i < n and a[i] <= pc:
			seq.append(a[i])
			i += 1
		elif j < m and b[j] <= pc:
			seq.append(b[j])
			j += 1
		else:
			print(-1)
			printed = True
			break
	if not printed:
		print(*seq)
for _ in range(getInt()):
	solve()


t = int(input())

def solve(k):
	(i, j) = (0, 0)
	is_stuck = False
	sequence = []
	while not is_stuck and i < n and (j < m):
		if A[i] <= k:
			k += A[i] == 0
			sequence.append(str(A[i]))
			i += 1
		elif B[j] <= k:
			k += B[j] == 0
			sequence.append(str(B[j]))
			j += 1
		else:
			is_stuck = True
	while not is_stuck and i < n:
		if A[i] <= k:
			k += A[i] == 0
			sequence.append(str(A[i]))
			i += 1
		else:
			is_stuck = True
	while not is_stuck and j < m:
		if B[j] <= k:
			k += B[j] == 0
			sequence.append(str(B[j]))
			j += 1
		else:
			is_stuck = True
	return -1 if is_stuck else ' '.join(sequence)
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ans = solve(k)
	print(ans)


for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.reverse()
	b.reverse()
	ans = []
	while a and b:
		if a[-1] == 0:
			ans.append(a.pop())
		elif b[-1] == 0:
			ans.append(b.pop())
		elif a[-1] <= b[-1]:
			ans.append(a.pop())
		else:
			ans.append(b.pop())
	ans += a[::-1] + b[::-1]
	for i in ans:
		if i == 0:
			k += 1
		elif i > k:
			print(-1)
			break
	else:
		print(*ans)


PI = 3.141592653589793
INF = float('inf')
MOD = 1000000007

def bin32(num):
	return '{0:032b}'.format(num)

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

def sub(x, y):
	return (x - y + MOD) % MOD

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

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

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

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

def ls():
	return [i for i in input().split()]
for t in range(ii()):
	t += 1
	input()
	(k, n, m) = li()
	a = li()
	b = li()
	ans = []
	x = 0
	y = 0
	flag = 1
	while x < n or y < m:
		if x < n and y < m:
			if a[x] == 0:
				ans.append(0)
				x += 1
				k += 1
			elif b[y] == 0:
				ans.append(0)
				y += 1
				k += 1
			elif a[x] < b[y]:
				if a[x] <= k:
					ans.append(a[x])
				else:
					flag = 0
					break
				x += 1
			else:
				if b[y] <= k:
					ans.append(b[y])
				else:
					flag = 0
					break
				y += 1
		elif x == n:
			if b[y] <= k:
				ans.append(b[y])
				if b[y] == 0:
					k += 1
			else:
				flag = 0
				break
			y += 1
		else:
			if a[x] <= k:
				ans.append(a[x])
				if a[x] == 0:
					k += 1
			else:
				flag = 0
				break
			x += 1
	if flag:
		print(*ans)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ap = 0
	bp = 0
	ans = []
	while True:
		if ap == len(a) and bp == len(b):
			break
		if ap < len(a) and a[ap] == 0:
			ans += [a[ap]]
			ap += 1
			k += 1
		elif bp < len(b) and b[bp] == 0:
			ans += [b[bp]]
			bp += 1
			k += 1
		elif ap < len(a) and a[ap] <= k or (bp < len(b) and b[bp] <= k):
			if bp == len(b):
				ans += [a[ap]]
				ap += 1
			elif ap == len(a):
				ans += [b[bp]]
				bp += 1
			elif a[ap] < b[bp]:
				ans += [a[ap]]
				ap += 1
			else:
				ans += [b[bp]]
				bp += 1
		else:
			print(-1)
			break
	if len(ans) == m + n:
		print(*ans)


def f(a, b, k):
	n = len(a)
	m = len(b)
	res = list()
	i = j = 0
	while i < n and j < m:
		if 0 < a[i] <= k:
			res.append(a[i])
			i += 1
		elif a[i] == 0:
			res.append(0)
			k += 1
			i += 1
		elif 0 < b[j] <= k:
			res.append(b[j])
			j += 1
		elif b[j] == 0:
			res.append(0)
			k += 1
			j += 1
		else:
			return [-1]
	while i < n:
		if 0 < a[i] <= k:
			res.append(a[i])
			i += 1
		elif a[i] == 0:
			res.append(0)
			k += 1
			i += 1
		else:
			return [-1]
	while j < m:
		if 0 < b[j] <= k:
			res.append(b[j])
			j += 1
		elif b[j] == 0:
			res.append(0)
			k += 1
			j += 1
		else:
			return [-1]
	return res
t = int(input())
g = []
for _ in range(t):
	input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	g.append(f(a, b, k))
for _ in g:
	print(*_)


t = int(input())
for _ in range(t):
	input()
	(k, a, b) = list(map(int, input().split()))
	ai = list(map(int, input().split()))
	bi = list(map(int, input().split()))

	def isPossible(k, ai, bi):
		(aptr, bptr) = (0, 0)
		ordering = []
		while aptr < len(ai) and bptr < len(bi):
			while aptr < len(ai) and k >= ai[aptr]:
				ordering.append(ai[aptr])
				k += ordering[-1] == 0
				aptr += 1
			while bptr < len(bi) and k >= bi[bptr]:
				ordering.append(bi[bptr])
				k += ordering[-1] == 0
				bptr += 1
			if aptr >= len(ai) and bptr >= len(bi):
				break
			if (aptr >= len(ai) or k < ai[aptr]) and (bptr >= len(bi) or k < bi[bptr]):
				return [-1]
		while aptr < len(ai):
			ordering.append(ai[aptr])
			if ordering[-1] > k:
				return [-1]
			k += ordering[-1] == 0
			aptr += 1
		while bptr < len(bi):
			ordering.append(bi[bptr])
			if ordering[-1] > k:
				return [-1]
			k += ordering[-1] == 0
			bptr += 1
		return ordering
	print(*isPossible(k, ai, bi))


t = int(input())
for _ in range(t):
	_ = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	lst = [a, b]
	i = 0
	c = 0
	s = []
	ok = 1
	while c < n + m and ok:
		if not lst[i]:
			i = not i
		ne = lst[i][0]
		if ne > k:
			i = not i
			if not lst[i] or lst[i][0] > k:
				ok = 0
				break
			continue
		if ne == 0:
			k += 1
		c += 1
		s.append(lst[i].pop(0))
	if not ok:
		s = [-1]
	print(' '.join(map(str, s)))


from sys import stdin, stdout
input = stdin.readline

def main():
	t = int(input())
	for z in range(t):
		input()
		(k, n, m) = map(int, input().split())
		ai = list(map(int, input().split()))
		bi = list(map(int, input().split()))
		ans = []
		num = k
		(ia, ib) = (0, 0)
		for i in range(n + m):
			if ia < n and ai[ia] == 0:
				ans += [0]
				ia += 1
				num += 1
				continue
			if ib < m and bi[ib] == 0:
				ans += [0]
				ib += 1
				num += 1
				continue
			if ia < n and ai[ia] <= num:
				ans += [ai[ia]]
				ia += 1
				continue
			if ib < m and bi[ib] <= num:
				ans += [bi[ib]]
				ib += 1
				continue
			ans = [-1]
			break
		print(*ans)
main()


for i in range(int(input())):
	input()
	(k, n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))[::-1]
	b = list(map(int, input().split(' ')))[::-1]
	idx = 0
	ans = []
	while idx < n + m and (a or b):
		if a and a[-1] == 0:
			k += 1
			ans.append('0')
			a.pop()
		elif a and a[-1] > 0 and (a[-1] <= k):
			ans.append(str(a[-1]))
			a.pop()
		elif b and b[-1] == 0:
			k += 1
			ans.append('0')
			b.pop()
		elif b and b[-1] > 0 and (b[-1] <= k):
			ans.append(str(b[-1]))
			b.pop()
		else:
			ans = -1
			break
		idx += 1
	if ans == -1:
		print(-1)
	elif len(ans) != m + n:
		print(-1)
	else:
		print(' '.join(ans))


import sys
input = sys.stdin.readline

def main():
	q = int(input())
	input()
	for pp in range(q):
		(k, n, m) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if pp != q - 1:
			input()
		solve(k, n, m, a, b)

def solve(k, n, m, a, b):
	(i, j) = (0, 0)
	res = []
	while i < n or j < m:
		if i < n and a[i] <= k:
			res.append(a[i])
			if a[i] == 0:
				k += 1
			i += 1
		elif j < m and b[j] <= k:
			res.append(b[j])
			if b[j] == 0:
				k += 1
			j += 1
		else:
			res = [-1]
			break
	print(*res)
	pass
main()


t = int(input())
while t:
	t -= 1
	s = input()
	(k, n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	(i, j) = (0, 0)
	ans = []
	while len(ans) < n + m:
		if i < n and a[i] == 0:
			ans.append(0)
			k += 1
			i += 1
		elif j < m and b[j] == 0:
			ans.append(0)
			k += 1
			j += 1
		elif i < n and a[i] <= k:
			ans.append(a[i])
			i += 1
		elif j < m and b[j] <= k:
			ans.append(b[j])
			j += 1
		else:
			break
	if len(ans) == n + m:
		print(*ans)
	else:
		print(-1)


def actions():
	space = input()
	(k, n, m) = map(int, input().split())
	monocarp = list(map(int, input().split()))
	polycarp = list(map(int, input().split()))
	pages = set(range(1, k + 1))
	if len(pages) == 0:
		pages.add(0)
	sequence = []
	while len(polycarp) > 0 or len(monocarp) > 0:
		if len(polycarp) > 0 and polycarp[0] == 0:
			pages.add(max(pages) + 1)
			sequence.append(polycarp.pop(0))
			continue
		elif len(monocarp) > 0 and monocarp[0] == 0:
			pages.add(max(pages) + 1)
			sequence.append(monocarp.pop(0))
			continue
		elif len(polycarp) > 0 and polycarp[0] in pages:
			sequence.append(polycarp.pop(0))
			continue
		elif len(monocarp) > 0 and monocarp[0] in pages:
			sequence.append(monocarp.pop(0))
			continue
		return ['-1']
	sequence = list(map(str, sequence))
	return sequence
ans = []
t = int(input())
for i in range(t):
	ans.append(actions())
for i in ans:
	print(' '.join(i))


def main():
	for _ in range(int(input())):
		l = input()
		(k, n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		cnt = k
		ans = []
		i = j = 0
		flag = 1
		while i < n and j < m and flag:
			flag = 0
			if a[i] == 0:
				ans.append(a[i])
				i += 1
				cnt += 1
				flag = 1
			elif a[i] <= cnt and cnt > 0:
				ans.append(a[i])
				i += 1
				flag = 1
			if b[j] == 0:
				ans.append(b[j])
				j += 1
				cnt += 1
				flag = 1
			elif b[j] <= cnt and cnt > 0:
				ans.append(b[j])
				j += 1
				flag = 1
		while i < n:
			if a[i] == 0:
				ans.append(a[i])
				cnt += 1
			elif a[i] <= cnt and cnt > 0:
				ans.append(a[i])
			else:
				ans = -1
				break
			i += 1
		if ans != -1:
			while j < m:
				if b[j] == 0:
					cnt += 1
					ans.append(b[j])
				elif b[j] <= cnt and cnt > 0:
					ans.append(b[j])
				else:
					ans = -1
					break
				j += 1
		if ans != -1:
			print(*ans)
		else:
			print(ans)
main()


import fileinput

def main():
	it = fileinput.input()
	num_cases = int(next(it))
	for i in range(num_cases):
		next(it)
		(k, _, _) = list(map(int, next(it).split()))
		a = list(map(int, next(it).split()))
		b = list(map(int, next(it).split()))
		i = 0
		j = 0
		actions = []
		has_sequence = True
		a_len = len(a)
		b_len = len(b)
		while True:
			if a_len == i and b_len == j:
				break
			if i < a_len and a[i] <= k:
				actions.append(a[i])
				if a[i] == 0:
					k += 1
				i += 1
			elif j < b_len and b[j] <= k:
				actions.append(b[j])
				if b[j] == 0:
					k += 1
				j += 1
			else:
				has_sequence = False
				break
		if has_sequence:
			print(' '.join(map(str, actions)))
		else:
			print(-1)
main()


t = int(input())
for _ in range(t):
	_ = input()
	(k, n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	buf = []
	for _ in range(n + m):
		if len(a) == 0 or len(b) == 0:
			if len(a) == 0:
				buf.extend(b)
				break
			else:
				buf.extend(a)
				break
		if a[0] >= b[0]:
			buf.append(b[0])
			b = b[1:]
		else:
			buf.append(a[0])
			a = a[1:]
	cop = buf[:]
	for i in range(n + m):
		x = cop[0]
		cop = cop[1:]
		if x == 0:
			k += 1
		if x > k:
			print(-1)
			break
		if i == n + m - 1:
			print(*buf)


t = int(input())
for i in range(t):
	space = input()
	(k, n, m) = map(int, input().split())
	taskN = list(map(int, input().split()))
	taskM = list(map(int, input().split()))
	ans = []
	possible = 0
	while len(taskM) > 0 or len(taskN) > 0:
		lenM = len(taskM)
		lenN = len(taskN)
		if lenM > 0 and taskM[0] == 0:
			k += 1
			ans.append(0)
			taskM.pop(0)
		elif lenN > 0 and taskN[0] == 0:
			k += 1
			ans.append(0)
			taskN.pop(0)
		elif lenN > 0 and taskN[0] <= k:
			ans.append(taskN[0])
			taskN.pop(0)
		elif lenM > 0 and taskM[0] <= k:
			ans.append(taskM[0])
			taskM.pop(0)
		else:
			possible = 1
			break
	if possible == 1:
		print(-1)
	else:
		print(*ans)


for _ in range(int(input().strip())):
	t = input().strip()
	(k, n, m) = map(int, input().strip().split())
	A = list(map(int, input().strip().split()))
	B = list(map(int, input().strip().split()))
	(lineCount, a, b) = (k, 0, 0)
	flag = True
	seq = []
	while flag and (a < n or b < m):
		if a < n and A[a] == 0:
			seq.append('0')
			lineCount += 1
			a += 1
		elif a < n and A[a] <= lineCount:
			seq.append(str(A[a]))
			a += 1
		elif b < m and B[b] == 0:
			seq.append('0')
			lineCount += 1
			b += 1
		elif b < m and B[b] <= lineCount:
			seq.append(str(B[b]))
			b += 1
		else:
			flag = False
	if flag:
		print(' '.join(seq))
	else:
		print('-1')


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
import heapq
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'
mod = 10 ** 9 + 7

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

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

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	for _ in range(ii()):
		I()
		(k, n, m) = mi()
		arr = li()
		brr = li()
		f = 1
		i = 0
		j = 0
		ans = []
		while i < n and j < m:
			if arr[i] <= k:
				ans.append(arr[i])
				if arr[i] == 0:
					k += 1
				i += 1
			elif brr[j] <= k:
				ans.append(brr[j])
				if brr[j] == 0:
					k += 1
				j += 1
			else:
				f = 0
				break
		while i < n:
			ans.append(arr[i])
			if arr[i] > k:
				f = 0
				break
			elif arr[i] == 0:
				k += 1
			i += 1
		while j < m:
			ans.append(brr[j])
			if brr[j] > k:
				f = 0
				break
			elif brr[j] == 0:
				k += 1
			j += 1
		if f == 0:
			print(-1)
		else:
			print(*ans)
main()


def solve(k, n, m, a, b):
	i = 0
	j = 0
	s = []
	for _ in range(n + m):
		if i < n and a[i] == 0:
			s.append(a[i])
			i += 1
			k += 1
			continue
		if j < m and b[j] == 0:
			s.append(b[j])
			j += 1
			k += 1
			continue
		if i < n and a[i] <= k:
			s.append(a[i])
			i += 1
			continue
		if j < m and b[j] <= k:
			s.append(b[j])
			j += 1
			continue
		return -1
	return ' '.join(map(str, s))
t = int(input())
for i in range(t):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(k, n, m, a, b))


t = int(input())
for _ in range(t):
	dummy = input()
	(k, m, n) = list(map(int, input().rstrip().split()))
	arrm = list(map(int, input().rstrip().split()))
	arrn = list(map(int, input().rstrip().split()))
	final = []
	pm = 0
	pn = 0
	count = 0
	while pm < m or pn < n:
		if pm < m and arrm[pm] == 0:
			final.append(arrm[pm])
			pm += 1
			k += 1
		elif pn < n and arrn[pn] == 0:
			final.append(arrn[pn])
			pn += 1
			k += 1
		elif pm < m and arrm[pm] <= k:
			final.append(arrm[pm])
			pm += 1
		elif pn < n and arrn[pn] <= k:
			final.append(arrn[pn])
			pn += 1
		else:
			break
	if pm < m or pn < n:
		print(-1)
	else:
		print(*final)


for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = []
	x = y = 0
	for i in range(n + m):
		if x < n and a[x] == 0:
			res.append(a[x])
			x += 1
			k += 1
			continue
		if y < m and b[y] == 0:
			res.append(b[y])
			y += 1
			k += 1
			continue
		if x < n and a[x] <= k:
			res.append(a[x])
			x += 1
			continue
		if y < m and b[y] <= k:
			res.append(b[y])
			y += 1
			continue
		print(-1)
		break
	else:
		print(*res)


import sys
from string import ascii_lowercase as alph
input = sys.stdin.readline

def print(*args, end='\n', sep=' '):
	sys.stdout.write(sep.join(map(str, args)) + end)

def solve():
	input()
	(k, _, _) = map(int, input().split())
	a = list(map(int, input().split()))[::-1]
	b = list(map(int, input().split()))[::-1]
	out = []
	while a or b:
		if a and a[-1] == 0:
			out.append(a.pop())
			k += 1
		elif b and b[-1] == 0:
			out.append(b.pop())
			k += 1
		elif a and a[-1] <= k:
			out.append(a.pop())
		elif b and b[-1] <= k:
			out.append(b.pop())
		else:
			print(-1)
			break
	else:
		print(*out)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


for u in range(int(input())):
	s = input()
	(k, n, m) = map(int, input().split())
	x = [int(w) for w in input().split()]
	y = [int(w) for w in input().split()]
	p = False
	i = 0
	j = 0
	z = []
	while i < n or j < m:
		if i < n and j < m:
			if x[i] < y[j]:
				z.append(x[i])
				i += 1
			else:
				z.append(y[j])
				j += 1
		elif i < n:
			z.append(x[i])
			i += 1
		else:
			z.append(y[j])
			j += 1
	v = 0
	for i in range(len(z)):
		if z[i] == 0:
			v += 1
		elif z[i] <= v + k:
			continue
		else:
			p = True
	if p:
		print(-1)
	else:
		print(*z)


t = int(input())
for i in range(t):
	_ = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = True
	c = []
	(i, j) = (0, 0)
	while len(c) < m + n:
		better = 0
		if i == len(a):
			better = b[j]
			j += 1
		elif j == len(b):
			better = a[i]
			i += 1
		elif a[i] < b[j]:
			better = a[i]
			i += 1
		else:
			better = b[j]
			j += 1
		c.append(better)
		if better == 0:
			k += 1
		elif k < better:
			res = False
			break
	if res:
		st = ''
		for c_ in c:
			st = st + f'{c_} '
		print(st[:-1])
	else:
		print(-1)


def fun(mon, pol, k):
	n = len(mon)
	m = len(pol)
	i = 0
	j = 0
	ans = ''
	while i < n or j < m:
		flag = False
		if i < n:
			if mon[i] == 0:
				ans += str(mon[i]) + ' '
				i += 1
				k += 1
				flag = True
			elif mon[i] <= k:
				ans += str(mon[i]) + ' '
				i += 1
				flag = True
		if j < m:
			if pol[j] == 0:
				ans += str(pol[j]) + ' '
				j += 1
				k += 1
				flag = True
			elif pol[j] <= k:
				ans += str(pol[j]) + ' '
				j += 1
				flag = True
		if not flag:
			return -1
	return ans
t = int(input())
for i in range(t):
	input()
	(k, n, m) = map(int, input().split())
	mon = list(map(int, input().split()))
	pol = list(map(int, input().split()))
	print(fun(mon, pol, k))


for _ in range(int(input())):
	p = input()
	(t, a, b) = map(int, input().split(' '))
	arr = []
	arr.append(list(map(int, input().split(' '))))
	arr.append(list(map(int, input().split(' '))))
	ptar = []
	for x in range(a + b):
		if arr[0] and arr[0][0] <= t:
			ptar.append(arr[0][0])
			if arr[0][0] == 0:
				t += 1
			arr[0].pop(0)
		elif arr[1] and arr[1][0] <= t:
			ptar.append(arr[1][0])
			if arr[1][0] == 0:
				t += 1
			arr[1].pop(0)
		else:
			ptar = [-1]
			break
	print(*ptar)


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
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 binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def primeFactorsCount(n):
	cnt = 0
	while n % 2 == 0:
		cnt += 1
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt += 1
			n = n // i
	if n > 2:
		cnt += 1
	return cnt

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s
for xyz in range(0, int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pa = pb = 0
	ans = []
	for i in range(0, n + m):
		if pa < n and a[pa] == 0:
			ans.append(0)
			k += 1
			pa += 1
		elif pb < m and b[pb] == 0:
			ans.append(0)
			k += 1
			pb += 1
		elif pa < n and a[pa] <= k:
			ans.append(a[pa])
			pa += 1
		elif pb < m and b[pb] <= k:
			ans.append(b[pb])
			pb += 1
		else:
			ans = [-1]
			break
	print(*ans)


t = int(input())
for _ in range(t):
	random = input()
	(k, n, m) = [int(i) for i in input().split(' ')]
	an = [int(i) for i in input().split(' ')]
	am = [int(i) for i in input().split(' ')]
	i = j = 0
	sol = []
	while True:
		if i < n and an[i] <= k:
			if an[i] == 0:
				k += 1
			sol.append(an[i])
			i += 1
		elif j < m and am[j] <= k:
			if am[j] == 0:
				k += 1
			sol.append(am[j])
			j += 1
		else:
			break
	if i < n or j < m:
		sol = [-1]
	for i in sol:
		print(i, end=' ')
	print()


_ = int(input())
for __ in range(_):
	___ = input()
	(k, n, m) = map(int, input().split())
	t11 = list(map(int, input().split()))
	t22 = list(map(int, input().split()))
	t1 = t11[::-1]
	t2 = t22[::-1]
	w = []
	f = False
	for z in range(n + m):
		if t1 and t2:
			if t1[-1] <= t2[-1]:
				tmp_item = t1.pop()
			else:
				tmp_item = t2.pop()
		elif not t1:
			tmp_item = t2.pop()
		elif not t2:
			tmp_item = t1.pop()
		if tmp_item > k:
			f = True
			break
		else:
			w.append(str(tmp_item))
			if tmp_item == 0:
				k += 1
	if f:
		print('-1')
	else:
		print(' '.join(w))


import math
import heapq
from collections import deque, Counter, defaultdict
string = ''
array = []

def solve(lines, a, b):
	(l, r) = (0, 0)
	q = []
	while l < len(a) or r < len(b):
		if l != len(a) and a[l] <= lines:
			q.append(a[l])
			if a[l] == 0:
				lines += 1
			l += 1
		elif r != len(b) and b[r] <= lines:
			q.append(b[r])
			if b[r] == 0:
				lines += 1
			r += 1
		else:
			return [-1]
	return q
ncases = int(input())
while ncases:
	_ = input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = solve(k, a, b)
	print(' '.join((str(i) for i in ans)))
	ncases -= 1


t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(i, j) = (0, 0)
	c = []
	f = 1
	while f == 1:
		f = 0
		while i < n and a[i] <= k:
			c.append(a[i])
			if a[i] == 0:
				k += 1
			i += 1
			f = 1
		while j < m and b[j] <= k:
			c.append(b[j])
			if b[j] == 0:
				k += 1
			j += 1
			f = 1
	if f == 0 and (i < n or j < m):
		print(-1)
	else:
		print(*c)


t = int(input())
for _ in range(t):
	input()
	no_exist = False
	res = []
	(k, n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(n + m):
		if len(a) > 0 and (a[0] <= k or a[0] == 0):
			if a[0] == 0:
				k += 1
			res.append(str(a.pop(0)))
		elif len(b) > 0 and (b[0] <= k or b[0] == 0):
			if b[0] == 0:
				k += 1
			res.append(str(b.pop(0)))
		elif len(a) == 0 and len(b) == 0:
			break
		else:
			no_exist = True
	if no_exist:
		print('-1')
	else:
		print(' '.join(res))


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


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	w = list(map(int, input().split()))
	s = list(map(int, input().split()))
	d = []
	(i, j) = (0, 0)
	while i < n or j < m:
		if i < n and w[i] <= k:
			if w[i] == 0:
				k += 1
			d.append(w[i])
			i += 1
		elif j < m and s[j] <= k:
			if s[j] == 0:
				k += 1
			d.append(s[j])
			j += 1
		else:
			d = [-1]
			break
	print(' '.join(map(str, d)))


t = int(input())
q = []
for i in range(t):
	input()
	(k, n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	q.append([k, a, b])
for w in q:
	k = w[0]
	a = w[1]
	b = w[2]
	i = 0
	j = 0
	seq = []
	temp1 = 0
	temp2 = 0
	while i < len(a) and j < len(b):
		temp1 = i
		temp2 = j
		if a[i] == 0:
			seq.append(a[i])
			i += 1
			k += 1
		elif b[j] == 0:
			seq.append(b[j])
			j += 1
			k += 1
		elif a[i] <= k:
			seq.append(a[i])
			i += 1
		elif b[j] <= k:
			seq.append(b[j])
			j += 1
		if i == temp1 and j == temp2:
			break
	while i < len(a):
		temp1 = i
		if a[i] == 0:
			seq.append(a[i])
			i += 1
			k += 1
		elif a[i] <= k:
			seq.append(a[i])
			i += 1
		if i == temp1:
			break
	while j < len(b):
		temp2 = j
		if b[j] == 0:
			seq.append(b[j])
			j += 1
			k += 1
		elif b[j] <= k:
			seq.append(b[j])
			j += 1
		if temp2 == j:
			break
	if len(seq) == len(a) + len(b):
		print(' '.join(map(str, seq)))
	else:
		print(-1)


t = int(input())
mod = 10 ** 9 + 7
while t:
	t -= 1
	input()
	arr = list(map(int, input().split()))
	(ct, n, m) = (arr[0], arr[1], arr[2])
	op1 = list(map(int, input().split()))
	op2 = list(map(int, input().split()))
	i = 0
	j = 0
	done = True
	ops = []
	while (i < n or j < m) and done:
		done = False
		if i < n and op1[i] == 0:
			done = True
			ct += 1
			ops.append(op1[i])
			i += 1
		elif i < n and op1[i] != 0 and (op1[i] <= ct):
			done = True
			ops.append(op1[i])
			i += 1
		elif j < m and op2[j] == 0:
			done = True
			ct += 1
			ops.append(op2[j])
			j += 1
		elif j < m and op2[j] != 0 and (op2[j] <= ct):
			done = True
			ops.append(op2[j])
			j += 1
	if done:
		stri = ''
		for i in ops:
			stri += str(i) + ' '
		print(stri)
	else:
		print(-1)


def main():
	for _ in range(int(input())):
		input()
		(k, n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		ai = 0
		bi = 0
		ansf = True
		ans = []
		while ai < n or bi < m:
			ansf = False
			while ai < n and a[ai] <= k:
				if a[ai] == 0:
					k += 1
				ans.append(a[ai])
				ai += 1
				ansf = True
			while bi < m and b[bi] <= k:
				if b[bi] == 0:
					k += 1
				ans.append(b[bi])
				bi += 1
				ansf = True
			if not ansf:
				break
		for i in range(ai, n):
			if a[i] > k:
				anf = False
				break
			ans.append(a[i])
		for i in range(bi, m):
			if b[i] > k:
				anf = False
				break
			ans.append(b[i])
		if ansf:
			print(*ans)
		else:
			print(-1)
main()


def task():
	input()
	(k, n, m) = [int(x) for x in input().split()]
	(arr1, arr2) = ([int(x) for x in input().split()], [int(x) for x in input().split()])
	(L1, L2) = (len(arr1), len(arr2))
	(i, j) = (0, 0)
	inf = float('inf')
	ans = []
	while i != L1 or j != L2:
		if i != L1 and arr1[i] == 0:
			k += 1
			i += 1
			ans.append(0)
		elif j != L2 and arr2[j] == 0:
			k += 1
			j += 1
			ans.append(0)
		else:
			x1 = arr1[i] if i != L1 else inf
			x2 = arr2[j] if j != L2 else inf
			if x1 <= k:
				i += 1
				ans.append(x1)
			elif x2 <= k:
				j += 1
				ans.append(x2)
			else:
				return -1
	return ' '.join([str(x) for x in ans])
T = int(input())
for _ in range(T):
	print(task())


import sys

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

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

def solve():
	input()
	(k, n, m) = ints()
	a = list(ints())
	b = list(ints())
	i = j = 0
	res = []
	while i < len(a) or j < len(b):
		if i < len(a) and a[i] == 0:
			res.append(a[i])
			k += 1
			i += 1
		elif j < len(b) and b[j] == 0:
			res.append(b[j])
			k += 1
			j += 1
		elif i < len(a) and a[i] <= k:
			res.append(a[i])
			i += 1
		elif j < len(b) and b[j] <= k:
			res.append(b[j])
			j += 1
		else:
			return [-1]
	return res
T = int(input())
for _ in range(T):
	print(*solve())


t = int(input())

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

def get_order(k, a, b):
	(n, m) = (len(a), len(b))
	order = []
	(i, j) = (0, 0)
	while i < n or j < m:
		if i < n and a[i] == 0:
			order.append(0)
			k += 1
			i += 1
		elif j < m and b[j] == 0:
			order.append(0)
			k += 1
			j += 1
		elif i < n and (j == m or a[i] <= b[j]):
			if a[i] <= k:
				order.append(a[i])
				i += 1
			else:
				return [-1]
		elif j < m and (i == n or a[i] > b[j]):
			if b[j] <= k:
				order.append(b[j])
				j += 1
			else:
				return [-1]
		else:
			return [-1]
	return order
for _ in range(t):
	input()
	(k, _, _) = read_ints()
	(a, b) = (read_ints(), read_ints())
	print(' '.join(map(str, get_order(k, a, b))))


t = int(input())
input()
for _ in range(t):
	(k, n, m) = (int(x) for x in input().split())
	(a, b) = ([int(x) for x in input().split()], [int(x) for x in input().split()])
	try:
		input()
	except:
		pass
	(i, j, c, arr) = (0, 0, k, [])
	while i + j < m + n:
		if i >= n:
			if b[j] > c:
				print(-1)
				break
			if b[j] == 0:
				c += 1
			arr.append(b[j])
			j += 1
		elif j >= m:
			if a[i] > c:
				print(-1)
				break
			if a[i] == 0:
				c += 1
			arr.append(a[i])
			i += 1
		elif b[j] > c and a[i] > c:
			print(-1)
			break
		elif b[j] > c:
			arr.append(a[i])
			if a[i] == 0:
				c += 1
			i += 1
		else:
			arr.append(b[j])
			if b[j] == 0:
				c += 1
			j += 1
	else:
		print(' '.join((str(x) for x in arr)))


from math import *
from sys import *
input = stdin.readline
for _ in range(int(input())):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	j = 0
	l = []
	cnt = 1
	while i < n or j < m:
		if i < n and a[i] == 0:
			l.append(a[i])
			i += 1
			k += 1
			continue
		if j < m and b[j] == 0:
			l.append(b[j])
			j += 1
			k += 1
			continue
		if i < n and k >= a[i]:
			l.append(a[i])
			i += 1
		elif j < m and k >= b[j]:
			l.append(b[j])
			j += 1
		else:
			cnt = 0
			break
	if cnt:
		print(*l)
	else:
		print(-1)


def solve(k, n, m, a, b):
	ans = []
	l = k
	(cura, curb) = (0, 0)
	noProg = 0
	while cura < n or curb < m:
		while cura < n:
			if a[cura] == 0:
				cura += 1
				l += 1
				ans.append(0)
				noProg = 0
			else:
				break
		while curb < m:
			if b[curb] == 0:
				curb += 1
				l += 1
				ans.append(0)
				noProg = 0
			else:
				break
		if cura < n:
			if l >= a[cura]:
				ans.append(a[cura])
				cura += 1
				noProg = 0
			else:
				noProg += 1
		if curb < m:
			if l >= b[curb]:
				ans.append(b[curb])
				curb += 1
				noProg = 0
			else:
				noProg += 1
		if noProg > 1:
			print(-1)
			return -1
	if cura == n and curb == m:
		print(*ans)
		return ans
	else:
		print(-1)
		return -1
t = int(input())
for case in range(t):
	throwaway = input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(k, n, m, a, b)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	input()
	(k, n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	d = 0
	an = []
	sign = 0
	while c < n and d < m:
		if a[c] == 0:
			k += 1
			an.append(a[c])
			c += 1
			if c == n:
				break
		elif b[d] == 0:
			k += 1
			an.append(b[d])
			d += 1
			if d == m:
				break
		elif a[c] <= k:
			an.append(a[c])
			c += 1
		elif b[d] <= k:
			an.append(b[d])
			d += 1
		else:
			sign = 1
			break
	if c == n:
		while d < m:
			if b[d] == 0:
				k += 1
				an.append(b[d])
				d += 1
				if d == m:
					break
			elif b[d] <= k:
				an.append(b[d])
				d += 1
			else:
				sign = 1
				break
	else:
		while c < n:
			if a[c] == 0:
				k += 1
				an.append(a[c])
				c += 1
				if c == n:
					break
			elif a[c] <= k:
				an.append(a[c])
				c += 1
			else:
				sign = 1
				break
	if sign:
		print(-1)
	else:
		print(*an)


for _ in range(int(input())):
	space = input()
	(k, n, m) = map(int, input().split())
	mono = list(map(int, input().split()))
	poly = list(map(int, input().split()))
	(i, j) = (0, 0)
	res = []
	for x in range(m + n):
		if i < n and (mono[i] == 0 or mono[i] <= k):
			if mono[i] == 0:
				k += 1
			res.append(mono[i])
			i += 1
		elif j < m and (poly[j] == 0 or poly[j] <= k):
			if poly[j] == 0:
				k += 1
			res.append(poly[j])
			j += 1
		else:
			res = [-1]
			break
	print(*res)


def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		input()
		(n, a, b) = map(int, input().split())
		A = list(map(int, input().split()))
		B = list(map(int, input().split()))
		z = A.count(0) + B.count(0)
		if z + n < max(max(A), max(B)):
			print(-1)
		else:
			l = []
			(i, j, f) = (0, 0, 1)
			while i < a or j < b:
				if i < a and A[i] == 0:
					l.append(A[i])
					i += 1
					n += 1
					continue
				if i < a and A[i] <= n:
					l.append(A[i])
					i += 1
					continue
				if j < b and B[j] == 0:
					l.append(B[j])
					j += 1
					n += 1
					continue
				if j < b and B[j] <= n:
					l.append(B[j])
					j += 1
					continue
				f = 0
				break
			if f:
				print(*l)
			else:
				print(-1)
main()


import sys
LI = lambda : list(map(int, sys.stdin.readline().split()))
MI = lambda : map(int, sys.stdin.readline().split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline())
from collections import deque
for _ in range(II()):
	input()
	(k, n, m) = MI()
	(a, b) = (deque(LI()), deque(LI()))
	r = []
	ok = 1
	while a or b:
		if a and a[0] == 0:
			r.append(0)
			a.popleft()
			k += 1
		elif b and b[0] == 0:
			r.append(0)
			b.popleft()
			k += 1
		elif a and a[0] <= k:
			r.append(a[0])
			a.popleft()
		elif b and b[0] <= k:
			r.append(b[0])
			b.popleft()
		else:
			ok = 0
			break
	if ok:
		print(*r)
	else:
		print(-1)