Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)


Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Buggy python submission (verdict: Time Limit Exceeded):

import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        for i, pp in enumerate(p):
            if pp == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)


Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Buggy python submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        for i, pp in enumerate(p):
            if pp == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)


Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue
            
        for i, pp in enumerate(p):
            if pp == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)


Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Buggy python submission (verdict: Time Limit Exceeded):

import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue
            
        for i, pp in enumerate(p):
            if pp == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)


Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Buggy python submission (verdict: Time Limit Exceeded):

import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue
            
        for i, pp in enumerate(p):
            if pp == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)


Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        m = len(p)

        for i in range(m):
            if p[i] == (i+1):
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

def bfs(b):
    q.put(b)

    while q.empty() == False:
        p = q.get()

        if p == []:
            break

        if ans.empty() == False:
            a = ans.get()
        else:
            a = []

        m = len(p)

        for i in range(m):
            if p[i] == (i+1):
                pp = p[:]
                pp.remove(i+1)
                q.put(pp)

                aa = a[:]
                aa.append(i+1)
                ans.put(aa)

    if p == []:
        a = ans.get()
        a = a[::-1]

        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)


Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)