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

0 2 0 5
0 2 0 5 6
-1
0 6 0 7 0 8 0 9
-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())
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
    while True:
        if i < n and r < m:
            if a[i] == 0:
                s += str(a[i])
                k += 1
                i += 1

            elif b[r] == 0:
                s += str(b[r])
                k += 1
                r += 1

            elif a[i] <= k:
                s += str(a[i])
                i += 1

            elif b[r] <= k:
                s += str(b[r])
                r += 1

            else:
                f = 1
                print("-1")
                break

        elif i < n and r >= m:
            if a[i] == 0:
                s += str(a[i])
                k += 1
                i += 1

            elif a[i] <= k:
                s += str(a[i])
                i += 1

            else:
                f = 1
                print("-1")
                break

        elif r < m and i >= n:
            if b[r] == 0:
                s += str(b[r])
                k += 1
                r += 1

            elif b[r] <= k:
                s += str(b[r])
                r += 1

            else:
                f = 1
                print("-1")
                break
        else:
            break
    if f == 0:
        print(s)
