CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
bs = list(map(int, input().split()))

ans = []  
 
def check(bs, pre):
  tmp = pre[:]
  if len(bs) == 0:
    ans.append(tmp)
    return
  cand = []
  for i, b in enumerate(bs):
    if i + 1 == b:
      cand.append(i)
  if len(cand) == 0:
    return
  for i in cand:
    check(bs[:i] + bs[i+1:], [i + 1] + tmp)

check(bs, [])

if len(ans):
  for ai in ans[0]:
    print(ai)
else:
  print((-1))


# Optimized solution
n = int(eval(input()))
bs = list(map(int, input().split()))

ans = []  
 
def check(bs, pre):
  tmp = pre[:]
  if len(bs) == 0:
    ans.append(tmp)
    return
  cand = []
  for i, b in enumerate(bs):
    if i + 1 == b:
      cand.append(i)
  if len(cand) == 0:
    return
  i = cand[-1]
  check(bs[:i] + bs[i+1:], [i + 1] + tmp)

check(bs, [])

if len(ans):
  for ai in ans[0]:
    print(ai)
else:
  print((-1))
# Original solution
def check_val(ind):
    if ind > len(b): return False 
    if b[ind-1] == ind:
        ans.append(ind)
        del b[ind-1]
        return True
    else:
        return False


N,*b = map(int,open(0).read().split())
if b[0] != 1: 
    print(-1)
    exit()

set_b = sorted(set(b),reverse=True)
ans = []
while len(b) != 0:
    flg = False
    for i in set_b:
        flg = check_val(i)
        if flg: break
    if set_b[-1] not in b: del set_b[-1]
else: #消せるものがなくなった
    if len(b) == 0:
        print(*ans[::-1],sep="\n")
    else:
        print(-1)
    
    


# Optimized solution
def check_val(ind):
    if ind > len(b): return False 
    if b[ind-1] == ind:
        ans.append(ind)
        del b[ind-1]
        if ind not in b: set_b.remove(ind)
        return True
    else:
        return False


N,*b = map(int,open(0).read().split())
if b[0] != 1: 
    print(-1)
    exit()

set_b = sorted(set(b),reverse=True)
ans = []

while len(b) != 0:
    flg = False
    for i in set_b:
        flg = check_val(i)
        if flg: break
    
    if flg == False:
        print(-1)
        exit() 
else: #消せるものがなくなった
    print(*ans[::-1],sep="\n")
# Original solution
N = int(eval(input()))
list_b = list(map(int, input().split()))
aaa = [[1, 1], [1, 2]]
ans = [[1, 1], [1, 2]]
for i in range(2,N):
  j = []
  f = []
  for d in range(len(aaa)):
    s = []
    t = []
    for k in range(i+1):
      a = aaa[d].copy()
      b = ans[d].copy()
      a.insert(k, k+1)
      b.append(k+1)
      s.append(a)
      t.append(b)
    j += s
    f += t
  aaa = j
  ans = f

if list_b in aaa:
  index = aaa.index(list_b)
  anser = ans[index]
  for i in range(N):
    print((anser[i]))
else:
  print('-1')

# Optimized solution
N = int(eval(input()))
list_b = list(map(int, input().split()))
ans = [0 for i in range(N)]

finish = False

for i in range(N-1, -1, -1):
  mx = -1
  for k in range(i+1):
    if list_b[k] == k+1:
      mx = max(mx, k+1)
  if mx == -1:
    finish = True
    break
  else:
    ans[i] = mx
    for j in range(mx-1, i):
      list_b[j] = list_b[j+1]
    
if not finish:
    for i in range(N):
        print((ans[i]))
else:
    print((-1))
# Original solution
import collections
N = int(eval(input()))
B = list(map(int, input().split()))


for i, b in enumerate(B, start=1):
  if b > i:
    print((-1))
    exit()


bnn = collections.defaultdict(
  lambda: collections.defaultdict(dict)
)
def inv_sousa(B, N, now=tuple()):
  if N == 0:
    yield now
  else:
    if now in bnn[B][N] or max(B) > N:
      return
    bnn[B][N][now] = False

    for i in set(B):
      idx = i - 1
      if B[idx] == i:
        yield from inv_sousa(B[:idx] + B[i:], N - 1, now=now + (B[idx],))


for x in inv_sousa(tuple(B), N):
  if x:
    for i in x[::-1]:
      print(i)
    break
else:
  print((-1))

# Optimized solution
N = int(eval(input()))
B = list(map(int, input().split()))


inv_output = list()
for i in range(N, 0, -1):
  for j in range(i, 0, -1):
    if B[j - 1] == j:
      inv_output.append(B.pop(j - 1))
      break
  else:
    print((-1))
    break
else:
  for i in inv_output[::-1]:
    print(i)
# Original solution
from collections import Counter
import sys
sys.setrecursionlimit(10**7)
n = int(input())
B = list(map(int, input().split()))
c = Counter(B)
A = []
history = []


def dfs(i):
    if i == n+1:
        if A == B:
            print(*history, sep='\n')
            exit()
        return 0
    for j in reversed(range(1, i+1)):
        if not c[j]:
            continue
        c[j] -= 1
        history.append(j)
        A.insert(j-1, j)
        dfs(i+1)
        A.pop(j-1)
        history.pop()
        c[j] += 1


dfs(1)
print(-1)


# Optimized solution
n = int(input())
B = list(map(int, input().split()))
A = []
for b in B:
    A.insert(b-1, b)
if all(A[i] <= i+1 for i in range(n)):
    C = []
    for a in A:
        C.insert(a-1, a)
    if B == C:
        print(*A, sep='\n')
    else:
        print(-1)
else:
    print(-1)
# Original solution
from collections import deque
def main():
    n = int(eval(input()))
    b = list(map(int, input().split()))
    s = set()
    q = deque()

    q.append([tuple(b), [0]*n, 0])
    ans = None
    while q:
        now, history, depth = q.popleft()
        if now in s:
            continue
        s.add(now)
        if len(now) == 0:
            ans = history
            break
        for i, j in enumerate(now):
            if i+1 == j:
                tmp = history[::]
                tmp[depth] = i+1
                q.appendleft([tuple(now[:i] + now[i+1:]), tmp, depth+1])
    if ans is None:
        print((-1))
    else:
        for i in ans[::-1]:
            if i == 0:
                break
            print(i)
if __name__ == "__main__":
    main()

# Optimized solution
n = int(eval(input()))
b = list(map(int, input().split()))

def check(b):
    for i in range(len(b))[::-1]:
        if i+1 == b[i]:
            return i
    return -1

ans = []
for i in range(n):
    ind = check(b)
    if ind >= 0:
        ans.append(ind+1)
        b = b[:ind] + b[ind+1:]
    else:
        print((-1))
        exit()
for i in ans[::-1]:
    print(i)
# Original solution
import copy

n = int(eval(input()))

goal = list(map(int, input().split(" ")))

output = -1

def searchAns(goal, temp, left, proc):
  #print(temp, left, proc)
  if len(left) == 0:
    if temp == goal:
      return proc
    else:
      return -1
  for num in left:
    #print(num, temp, left, proc)
    if num <= len(temp) + 1:
      copyTemp = copy.copy(temp)
      copyTemp.insert(num-1, num)
      copyLeft = copy.copy(left)
      copyLeft.remove(num)
      copyProc = copy.copy(proc)
      copyProc.append(num)
      result = searchAns(goal, copyTemp, copyLeft, copyProc)
      if result != -1:
        return result
  else:
    return -1
    
proc = searchAns(goal, [], goal, [])

if proc == -1:
  print((-1))
else:
  for num in proc:
    print(num)

# Optimized solution
import copy

n = int(eval(input()))

goal = list(map(int, input().split(" ")))

output = -1

procReverse = []

temp_goal = copy.copy(goal)

for _ in range(n):
  index = list(range(1,len(temp_goal)+1))
  for i in range(len(temp_goal)-1, -1, -1):
    #print(i, index, temp_goal)
    if index[i] == temp_goal[i]:
      procReverse.append(temp_goal[i])
      temp_goal.pop(i)
      break
  else:
    print((-1))
    break
else:
  for i in range(n-1, -1, -1):
    print((procReverse[i]))
# Original solution
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int,input().split()))
for i in range(n):
    if i+1 < a[i]:
        print((-1))
        exit()
 
def dfs(x,ans,so):
        if x == n:
                if ans == a:
                        so = so[::-1]
                        for i in so:
                                print(i)
                        exit()
                return 0
        for i in range(len(ans)):
            if ans[i] == i+1:
                ans.pop(i)
                so.append(i+1)
                dfs(x+1,ans,so)
                ans.insert(i,i+1)
                so.pop()
        return -1
print((dfs(0,a,[])))      

# Optimized solution
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int,input().split()))
for i in range(n):
    if i+1 < a[i]:
        print((-1))
        exit()
 
def dfs(x,ans,so):
        if x == n:
                if ans == a:
                        so = so[::-1]
                        for i in so:
                                print(i)
                        exit()
                return 0
        for i in range(len(ans)-1,-1,-1):
            if ans[i] == i+1:
                ans.pop(i)
                so.append(i+1)
                dfs(x+1,ans,so)
                ans.insert(i,i+1)
                so.pop()
        return -1
print((dfs(0,a,[])))
# Original solution
class Node:
    def __init__(self, prev, val, next):
        self.prev = prev
        self.val = val
        self.next = next


NIL = 0
START = -1
END = -2


class List:
    def __init__(self, li):
        li.append(END)
        self.li = [Node(NIL, START, NIL)]
        for e in li:
            node = Node(self.li[-1], e, NIL)
            self.li[-1].next = node
            self.li.append(node)

        self.l = len(self.li) - 1
        self.ans = []

    def step(self):
        i = self.l
        u = self.li[-1]
        while u.val != START:
            if u.val == i:
                u.prev.next = u.next
                u.next.prev = u.prev
                self.ans.append(u.val)
                self.l -= 1
                return True

            else:
                u = u.prev
                i -= 1

        self.ans = [-1]
        return False

    def solve(self):
        for _ in range(self.l - 1):
            if not self.step():
                break

        print(*self.ans[::-1], sep="\n")


def main():
    n = int(input())
    b = list(map(int, input().split()))

    l = List(b)
    l.solve()


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    n = int(input())
    b = list(map(int, input().split()))

    ans = []
    while b:
        l = len(b)
        for i in range(l)[::-1]:
            if b[i] == i + 1:
                pp = b.pop(i)
                ans.append(pp)
                break

        else:
            ans = [-1]
            break

    print(*ans[::-1], sep="\n")


if __name__ == "__main__":
    main()
# Original solution
import copy


def insertion(n, x):
    if not x:
        return True
    for i in range(n - 1, -1, -1):
        y = copy.copy(x)
        if y[i] == i + 1:
            y.pop(i)
            ope.insert(0, i + 1)
            if insertion(n - 1, y):
                return True
            else:
                ope.pop(0)
    return False


n = int(eval(input()))
b = list(map(int, input().split()))
ope = []
if insertion(n, b):
    for i in ope:
        print(i)
else:
    print((-1))


# Optimized solution
import sys


n = int(eval(input()))
b = list(map(int, input().split()))
ope = []
i = n
while i > 0:
    flag = 0
    j = i
    while j > 0:
        if b[j - 1] == j:
            b.pop(j - 1)
            i -= 1
            ope.insert(0, j)
            flag = 1
            break
        j -= 1
    if flag == 0:
        print((-1))
        sys.exit()
for i in ope:
    print(i)
# Original solution
import itertools

n = eval(input())
num_list = [int(i) for i in input().split()] 

is_possible = False

for order_list in list(itertools.permutations(num_list)):
  output_list = []
  
  if order_list[0] != 1:
    continue
  
  for x in order_list:
    output_list.insert(x - 1, x)
  
  if output_list == num_list:
    is_possible = True
    break
    
if is_possible:
  for out in order_list:
      print(out)
else:
  print((-1))

# Optimized solution
import itertools

n = eval(input())
num_list = [int(i) for i in input().split()] 

is_possible = False
permutations = list(set(itertools.permutations(num_list)))

for order_list in permutations:
  output_list = []
  
  if order_list[0] != 1:
    continue
  
  for x in order_list:
    output_list.insert(x - 1, x)
  
  if output_list == num_list:
    is_possible = True
    break
    
if is_possible:
  for out in order_list:
      print(out)
else:
  print((-1))
# Original solution
n = int(eval(input()))
b = list(map(int,input().split()))

ans = []
def solve(b,i):
    if i == 0:
        return True
    for j in range(i-1,-1,-1):
        if b[j] == j+1:
            p = b[:j] + b[j+1:]
            if solve(p,i-1):
                ans.append(j+1)
                return True


    return False

solve(b,n)
if len(ans) == n:
    for i in range(n):
        print((ans[i]))
else:
    print((-1))

# Optimized solution
n = int(eval(input()))
b = list(map(int,input().split()))

ans = []
def solve(b,i):
    if i == 0:
        return True
    for j in range(i-1,-1,-1):
        if b[j] > j+1:
            return False
        if b[j] == j+1:
            p = b[:j] + b[j+1:]
            if solve(p,i-1):
                ans.append(j+1)
                return True

    return False

solve(b,n)
if len(ans) == n:
    for i in range(n):
        print((ans[i]))
else:
    print((-1))
# Original solution
def remove(data):
    global result
    pos = min(len(data), max(data))
    for n in range(pos-1, -1, -1):
        if data[n] == n + 1:
            result.append(n + 1)
            if len(data) == 1:
                #print('OK')
                return True
            else:
                #print('remove {0} '.format(n + 1), end='')
                #print(data[:n] + data[n+1:])
                if remove(data[:n] + data[n+1:]):
                    return True
    else:
        #print('try again')
        if len(result) > 0:
            result.pop(-1)
        return False

_ = eval(input())
B = list(map(int, input().split()))

result = []

if remove(B):
    result.reverse()
    for res in result:
        print(res)
else:
    print((-1))


# Optimized solution
_ = eval(input())
data = list(map(int, input().split()))

result = []
pos = min(len(data), max(data)) - 1

while pos >= 0:
    if data[pos] == pos + 1:
        x = data.pop(pos)
        #print('remove {0} {1}'.format(x, data))
        result.append(x)
        if len(data) == 0:
            break
        pos = min(len(data), max(data)) - 1
    else:
        pos -= 1

if len(data) == 0:
    result.reverse()
    for res in result:
        print(res)
else:
    print((-1))
# Original solution
import sys
input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10 ** 7)  # NOQA


def dfs(N, a, i, b, procedure):
    if i == 0:
        return procedure

    for j in range(1, i+1):
        if a[j-1] == j:
            l = a[:]
            del l[j-1]
            p = procedure[:]
            p.append(j)
            ret = dfs(N, l, i-1, b, p)
            if ret is not None:
                return ret


def main():
    N = int(input())
    b = list(map(int, input().split()))

    res = dfs(N, b, N, b, [])
    if res is None:
        print(-1)
    else:
        print(*res[::-1], sep="\n")


if __name__ == "__main__":
    main()


# Optimized solution
import sys
input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10 ** 7)  # NOQA


def dfs(N, a, i, procedure):
    if i == 0:
        return procedure

    for j in reversed(range(1, i+1)):
        if a[j-1] == j:
            l = a[:]
            del l[j-1]
            p = procedure[:]
            p.append(j)
            ret = dfs(N, l, i-1, p)
            if ret is not None:
                return ret
            break


def main():
    N = int(input())
    b = list(map(int, input().split()))

    res = dfs(N, b, N, [])
    if res is None:
        print(-1)
    else:
        print(*res[::-1], sep="\n")


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
b = list(map(int, input().split()))
ans = []
def dfs(x):
    if x == []:
        return True
    ret = False
    for i, a in enumerate(x):
        if i + 1 == a:
            ret = dfs(x[:i] + x[i+1:])
            if ret:
                ans.append(a)
                break
    return ret
if dfs(b):
    for a in ans:
        print(a)
else:
    print((-1))

# Optimized solution
n = int(eval(input()))
b = list(map(int, input().split()))
ans = []
for k in range(n):
    for i in reversed(list(range(n - k))):
        a = b[i]
        if i + 1 == a:
            ans.append(b.pop(i))
            break
if b != []:
    print((-1))
else:
    for a in reversed(ans):
        print(a)
# Original solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


N = int(readline())
B = list(map(int, readline().split()))

def main():
    def dfs(vec):
        i = 0
        zero_only = True
        for j in range(len(vec)):
            if vec[j] > 0:
                zero_only = False
                i += 1
                if vec[j] == i:
                    vec[j] = 0
                    ret = dfs(vec)
                    vec[j] = i
                    if ret != False:
                        ret.append(i)
                        return ret
        if zero_only:
            return []
        else:
            return False

    ans = dfs(B)
    if ans == False:
        print(-1)
    else:
        print(*ans, sep='\n')

if __name__ == '__main__':
    main()


# Optimized solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


N = int(readline())
B = list(map(int, readline().split()))


def main():
    ans = []
    while B:
        found = False
        for i in range(len(B), 0, -1):
            if i == B[i - 1]:
                ans.append(i)
                del B[i - 1]
                found = True
                break
        if not found:
            print(-1)
            return
    print(*reversed(ans), sep='\n')


if __name__ == '__main__':
    main()
# Original solution
import sys
sys.setrecursionlimit(10**5)

def dfs(N, B, A, seq, nums):
  if len(A) == N:
    ok = True
    for a, b in zip(A, B):
      if a != b:
        ok = False
        break
    return seq if ok else None
  else:
    for n in list(nums.keys()):
      if nums[n] > 0:
        tmpA = A.copy()
        tmpSeq = seq.copy()
        tmpNums = nums.copy()
        tmpA.insert(n-1,n)
        tmpSeq.append(n)
        tmpNums[n] -= 1
        ans = dfs(N, B, tmpA, tmpSeq, tmpNums)
        if ans:
          return ans

N = int(eval(input()))
B = list(map(int, input().split()))
ok = True
nums = {b:0 for b in B}
for i, b in enumerate(B):
  if i+1<b:
    ok = False
    break
  nums[b] += 1
if ok:
  for n in dfs(N,B,[],[],nums):
    print(n)
else:
  print((-1))



# Optimized solution
import sys
sys.setrecursionlimit(10**5)

N = int(eval(input()))
B = list(map(int, input().split()))
ans = []
while len(B) > 0:
  ok = False
  for i in reversed(list(range(len(B)))):
    if B[i] == i+1:
      ok = True
      ans.append(B.pop(i))
      break
  if not ok:
    break
if len(B) > 0:
  print((-1))
else:
  for a in reversed(ans):
    print(a)
# Original solution
import copy
import queue


def main():
    N = int(eval(input()))
    B = [int(i) for i in input().split()]

    q = queue.Queue()
    q.put((B, []))

    def bfs(arr, indexes):
        if len(arr) == 0:
            return indexes

        for i in range(len(arr)):
            if i+1 == arr[i]:
                _indexes = copy.copy(indexes)
                _indexes.append(i)
                q.put((arr[:i] + arr[i+1:], _indexes))

        return False

    while not q.empty():
        item = q.get()
        res = bfs(item[0], item[1])
        if res:
            for i in reversed(res):
                print((i+1))
            return
    print((-1))
    return


main()


# Optimized solution
import copy

N = int(eval(input()))
B = [int(i) for i in input().split()]


def dfs(arr, indexes):
    if len(arr) == 0:
        return indexes

    for i in range(len(arr)):
        if i+1 == arr[i]:
            _indexes = copy.copy(indexes)
            _indexes.append(i)
            res = dfs(arr[:i] + arr[i+1:], _indexes)
            if res:
                return res
    return False


res = dfs(B, [])
if res:
    for i in reversed(res):
        print((i+1))
else:
    print((-1))
# Original solution
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())

C1 = S()
C2 = S()

if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
    print("YES")
else:
    print("NO")


# Optimized solution
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())

C1 = S()
C2 = S()

if C1[::-1] == C2:
    print("YES")
else:
    print("NO")
# Original solution
s1=str(input())
s2=str(input())
print('YES') if s1==s2[::-1] else print('NO')


# Optimized solution
print('YES') if input()==input()[::-1] else print('NO')
# Original solution
import math
from collections import defaultdict

def is_prime(n: int)-> bool:
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    # when n is a prime number
    # x^(n-1) ≡ 1 (mod n)
    return pow(2, (n-1), n) == 1


def prime_factorize(n: int):
    prime_factors = defaultdict(int)

    for i in range(2, int(math.sqrt(n)) + 1):
        if not is_prime(i):
            continue
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors[i] += 1
                n = div
            else:
                break
        if n == 1:
            break
    if n != 1:
        prime_factors[n] = 1

    return prime_factors


def main():
    N, P = list(map(int, input().split()))
    prime_factors = prime_factorize(P)

    gcd = 1
    for k, v in list(prime_factors.items()):
        v_cnt = v // N
        gcd *= pow(k, v_cnt)

    print(gcd)
    return

main()

# Optimized solution
import math
from collections import defaultdict

def prime_factorize(n: int):
    prime_factors = defaultdict(int)

    for i in range(2, int(math.sqrt(n)) + 1):
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors[i] += 1
                n = div
            else:
                break
        if n == 1:
            break
    if n != 1:
        prime_factors[n] = 1

    return prime_factors


def main():
    N, P = list(map(int, input().split()))
    prime_factors = prime_factorize(P)

    gcd = 1
    for k, v in list(prime_factors.items()):
        v_cnt = v // N
        gcd *= pow(k, v_cnt)

    print(gcd)
    return

main()
# Original solution
import sys

N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
if N == 1:
  print(P)
  sys.exit()
while P>1:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1
print(ans)


# Optimized solution
import sys

N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
if N == 1:
  print(P)
  sys.exit()
while P>i*i-4:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1
if P==i and c+1 ==N:
  ans*=i
print(ans)
# Original solution
n,p=list(map(int,input().split()))
 
if n==1:
    print(p)
else:
    x=round((p**(1/n)+1))+1
    for i in range(x,0,-1):        
                if p%(i**n)==0:
                    print(i)
                    break
 

# Optimized solution
N, P = list(map(int, input().split()))
ans = 1
 
if N >= 45:
  print(ans)
elif N == 1:
  print(P)
  
 
  
else:
  i = 1
  while(i**N <= P):
    if P % (i**N) == 0:
      ans = i
    i += 1
  print(ans)