n,*b=list(map(int,open(0).read().split()))

a=[]

while n:

  j=-1

  for i in range(n):

    if b[i]==i+1:

      j=i

  if j+1:

    b=b[:j]+b[j+1:]

    a+=[j+1]

  else:

    a=[-1]

    break

  n-=1

print((*a[::-1]))
n,*b=list(map(int,open(0).read().split()))

a=[]

while b:

  j=max(i*(i==v)for i,v in enumerate(b,1))

  if j:

    b=b[:j-1]+b[j:]

    a+=[j]

  else:

    a=[-1]

    break

print((*a[::-1]))
n, *b = list(map(int, open(0).read().split()))
a = []
while n:
    j = -1
    for i in range(n):
        if b[i] == i + 1:
            j = i
    if j + 1:
        b = b[:j] + b[j + 1 :]
        a += [j + 1]
    else:
        a = [-1]
        break
    n -= 1
print((*a[::-1]))

n, *b = list(map(int, open(0).read().split()))
a = []
while b:
    j = max(i * (i == v) for i, v in enumerate(b, 1))
    if j:
        b = b[: j - 1] + b[j:]
        a += [j]
    else:
        a = [-1]
        break
print((*a[::-1]))

-while n: -    j = -1 -    for i in range(n): -        if b[i] == i + 1: -            j = i -    if j + 1: -        b = b[:j] + b[j + 1 :] -        a += [j + 1] +while b: +    j = max(i * (i == v) for i, v in enumerate(b, 1)) +    if j: +        b = b[: j - 1] + b[j:] +        a += [j] -    n -= 1