np, nt = map(int, input().split(" "))

s = []
sp = []
ct = nt

for i in range(np):
    cs = int(input())
    if s and cs < s[-1][0]:
        ct -= 1
        
    # if s and cs == 0 and s[-1][0] > 0:
    #     print("ambiguous", flush=True)
    #     exit()
    
    if cs > 0:
        s.append([cs, ct])
        sp.append([cs, ct])
    else:
        s.append([cs, 0])
# print(s)

if sp and (sp[-1][1] != 1):
    print("ambiguous", flush=True)
    exit()

# if (s[0][0] > 0 and s[-1][0] == 0 and s[-1][1] != 0):
#     print("ambiguous", flush=True)
#     exit()

#or (s[-1][0] == 0 and s[-1][0] != 0)

# for i in range(np):
#     ci = np - i - 1
#     ni = ci - 1
#     s[ci][1] = ct

#     if ci == 0:
#         if ct != nt:
#             print("ambiguous", flush=True)
#             exit()
#         else:
#             break
#     if s[ci][0] < s[ni][0]:
#         ct += 1
#     if s[ci][0] == s[ni][0] and s[ci][0] != 0:
#         print("ambiguous", flush=True)
#         exit()
#     if s[ci][0] > 0 and s[ni][0] == 0:
#         print("ambiguous", flush=True)
#         exit()

for i in range(np):
    print(f"{s[i][1]}", flush=True)
