peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
li = list(map(int,input().split()))
li.append(100000)
f = 0
for i in range(1,n-1):
    if li[i-1] <= li[i] <= li[i+1]:
        f += 0
    elif li[i-1] <= li[i] - 1 <= li[i+1]:
        li[i] = li[i] - 1
        f += 0
    else:
        print("No")
        f = 1
        break
if f == 0:
    print("Yes")
import sys
n=int(input())
H=list(map(int,input().split()))

for i in range(1,n):
  if H[i-1]-H[i]>1 or H[i]-H[i-1]>1:
    print('No')
    exit()
print('Yes')
def main():
	n = int(input())
	arr = list(map(int,input().split()))
	for i in range(len(arr)-1):
		if arr[i]-1>(arr[i-1]-1):
			# print(i)
			print("No")
			return
	print("Yes")
	return


main()
n = int(input())
h = list(map(int, input().split()))

cur_h = h[0]
for i in range(1,n-2):
    if cur_h > h[i]+1:
        print("NO")
        exit()
    if cur_h > h[i]: cur_h = h[i]-1
    else: cur_h = h[i]

if h[n-1]+1 < cur_h: print("No") 
else: print("Yes")
n = int(input())
h = list(map(int, input().split()))
if n==1:
    print('Yes')
    exit()
for i in range(1,n):
    if h[i] < h[i-1]:
        h[i-1] -=1
if sorted(h) == h:
    print('Yes')
else:
    print('No')
N = int(input())
H = list(map(int,input().split()))

flag=0
for i in range(N-1):
    if H[i] > H[i+1]:
        flag=1
        break
    elif H[i]+1 == H[i+1]:
        H[i+1]=H[i+1]-1
    else:
        continue

if flag==0:
    print('Yes')
else:
    print('No')
n = int(input())
h = list(map(int, input().split()))

if max(h) - h[n - 1] > 1:
    print('No')
    exit(0)
elif n == 1:
    print('Yes')
    exit(0)
else:
    for i in range(n - 1 , 0):
        if max(h[i - 1] - 1, 1) > h[i]:
            print('No')
            exit(0)
        else:
            h[i - 1] = max(h[i - 1] - 1, 1)

print('Yes')
N=int(input())
H=list(map(int,input().split()))
num=0
for i in range(0,N-1):
    if H[i]==H[i+1]+1:
        H[i]=H[i]-1
    elif H[i]==H[i+1] and H[i]<H[i+1]:
        H[i]=H[i]
for n in range(0,N-1):
    if H[n]<=H[n+1]:
        num=num+1
if num==N-1:
    print("Yes")
else:
    print("No")
N = int(input())
A = list(map(int,input().split()))

at_least = A[-1]
for i in range(N-2, -1, -1):
  if A[i] > at_least:
    if A[i]-1 > at_least:
      print("No")
      exit()

print("Yes")
from sys import exit

N = int(input())
h = list(map(int,input().split()))

pre = h[0]-1
for i in range(N-1):
    if h[i] <= h[i+1]:
        pre = h[i]
    else:
        if h[i]-1 <= h[i+1]:
            if pre > h[i]-1:
                print("No")
                exit(0)
            else:
                pre = h[i]-1
        else:
            print("No")
            exit(0)

print("Yes")
n = int(input())
h = list(map(int,input().split()))

for i in range(n):
    if h[i] == h[i-1] -1:
        h[i-1] -= 1

for j in range(n-1):
    if h[j] > h[j+1]:
        print('No')
        break
else:
    print('Yes')
from collections import deque

N = int(input())
H = deque(map(float, input().split()))

prev = H.popleft()

for i in range(N-1):
    cor = H.popleft()
    if cor - prev < -1:
        print('No')
        exit()
        
    prev = cor

print('Yes')
n = int(input())
stair = input().split(' ')
flag = 0

for i in range(0, n - 1):
  if (int(stair[i]) < int(stair[i+1])):
    stair[i+1] = int(stair[i+1]) - 1

  if (int(stair[i]) > int(stair[i+1])):
    print("No")
    exit;


print("Yes")
N = int(input())
H_list = list(map(int, input().split()))
ans = "Yes"
for i in range(1, N-1):
    if H_list[i]<H_list[i-1]:
        H_list[i]-=1
    if H_list[i]<H_list[i-1]:
        ans = "No"
        break
    if i==0:
        pass
    else:
        if H_list[i]<H_list[i-1]:
            ans = "No"
            break
print(ans)
N=int(input())
H=list(map(int,input().split()))
num=0
for i in range(0,N-1):
    if H[i]==H[i+1]+1 and H[i-1]<H[i]:
        H[i]=H[i]-1
    else:
        H[i]=H[i]
for n in range(0,N-1):
    if H[n]<=H[n+1]:
        num=num+1
if num==N-1:
    print("Yes")
else:
    print("No")
n = int(input())
h = list(map(int,input().split()))
for i in range(1,n):
    if h[i] - h[i-1] == -1:
        h[i] += 1
    if h[i] - h[i - 1] == 0 or h[i] - h[i - 1] == 1:
        continue
    else:
        print("No")
        exit()
print("Yes")
N = int(input())
H = list(map(int,input().split()))
for i in range(N-1):
    if H[i] > H[i+1]:
        H[i] -= 1
if H == sorted(H):
    print('Yes')
else:
    print('No')
import sys

N = int(input())
H = list(map(int,input().split()))

for i in range(1,N-1):
    if not(H[i-1] <= H[i] <= H[i+1]):
        tmp = H[i] - 1
        if not(H[i-1] <= tmp <= H[i+1]):
            print('No')
            sys.exit()
        H[i] = tmp
    else:
        H[i] -= 1
print('Yes')
import sys
N = int(input())
H = list(map(int, input().split()))

for i in range(N-2):
  if H[i] >= H[i+1] > H[i+2]:
    print('No')
    sys.exit()
print('Yes')
n=int(input())

h=[int(x) for x in input().split()]
m=h[0]
for i in range(n):
  #print(c,-i)
  if h[i]>m+1:
    print("No")
    exit()
  m=max(m,h[i])
print("Yes")
N=int(input())
H=list(map(int, input().split()))
ans = "Yes"
for i in range(N-1)[::-1]:
	if H[i]<H[i-1]:
		H[i-1]-=1
		if H[i]<H[i-1]:
			ans="No"
			break
print(ans)
N=int(input())
h=list(map(int, input().split()))

ans = 'Yes'

for i in range(N-1):
    if h[i] <= h[i+1]:
        ans = 'Yes'
        continue
    if h[i] == (h[i+1]-1):
        ans = 'Yes'
        continue
    else:
        ans = 'No'
        break

print(ans)
n = int(input())
stair = input().split(' ')
flag = 0

for i in range(0, n - 1):
  if (int(stair[i]) == int(stair[i+1])):
    if (int(stair[i]) <= int(stair[i+1]) - 1):
      flag = 1
    else:
      flag = 0
      break;

if flag:
  print("Yes")
else:
  print("No")
N = int(input())
H = list(map(int,input().split()))
ans = 1
for i in range(N-1):
  if H[i] <= H[i+1]:
    pass
  elif H[i] == H[i+1]-1:
    H[i]-=1
  else:
    ans = 0
if ans == 1:
  print("Yes")
else:
  print("No")
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"
if N == 2:
    if H[0] > H[1]:
        ans = "No" 
else: 
    for i in range(N-2):
        if H[i] - H[i+2] >= 2 or H[i] - H[i+1] >= 2:
            ans = "No"
print(ans)
n = int(input())
h = list(map(int, input().split()))
for i in range(n - 2):
    if h[i] < h[i + 1] and h[i + 1] - h[i + 2] == 1:
        h[i + 1] -= 1
for i in range(n - 1):
    if h[i] > h[i + 1]:
        print("No")
        exit()
print("Yes")
n = int(input())
h = list(map(int, input().split()))
#b = list(map(int, input().split()))
flag = [0]*n
for i in range(n-1):
    if h[i]-h[i+1] >= 1:
        h[i] -= 1
        flag[i] = 1


if h[0]-h[-1] == 0:
    print("No")
    exit()
for i in range(n-1):
    if h[i] > h[i+1]:
        if h[i]-h[i+1] == 1 and flag[i] == 0:
            h[i] -= 1
        else:
            print("No")
            exit()

print("Yes")
n=int(input())
list=list(map(int,input().split()))
for i in range(n-1):
    if list[i]>list[i+1]:
        list[i]-=1
        if list[i+1]==max(list[0:i+1]):
             continue
        else:
            print("No")
            break
else:print("Yes")
N=int(input())
A=list(map(int, input().split()))
tmpmax=A[0]
ikeru=True
ok=True
for i in range(1,N):
  if tmpmax>A[i]:
    if tmpmax-1==A[i] and ok:
      tmpmax-=1
      ok=False
    else:
      ikeru=False
      break
  else:
    ok=True
    tmpmax=A[i]

if ikeru:
  print("Yes")
else:
  print("No")
N = int(input())
M = list(map(int,input().split()))

ans = "Yes"
limit = 0

for i in range(N-1) :
    if  M[i] > M[i+1] :
        if  M[i]-1 > M[i+1] or limit > M[i]-1 :
            ans = "No"
            break
    limit = M[i]
print(ans)
N=int(input())
H=list(map(int,input().split()))
for i in range(N-1):
    if H[i]==H[i+1]+1:
        H[i]-=1
        if H[i]<H[i-1]:
            print('No')
            exit()
    elif H[i]-H[i+1]>=2:
        print('No')
        exit()
print('Yes')
import numpy as np
import bisect
N = int(input())
H = list(map(int, input().split()))

tmp = H[bisect.bisect_right(H, max(H))-1:]
ans_1 = min(tmp) > max(H)-2

H = np.array(H)
tmp = H[1:] - H[:-1]

ans_2 = all(tmp > -2)

print("Yes") if ans_1 & ans_2 else print("No")
import sys


def main():

    N = int(sys.stdin.readline())
    Hs = [int(x) for x in sys.stdin.readline().strip().split(" ")]

    current = 0

    for i in range(N - 1):
        h_before = Hs[i]
        h_after = Hs[i + 1]

        if h_before <= h_after:
            continue

        if h_after < current:
            print("No")
            return

        h_before -= 1
        Hs[i] = h_before
        N = N - 1

        current = h_before

    print("Yes")


main()
n=int(input())
h=list(map(int, input().split()))
f=True

for i in range(n-1):
	j=i+1
	if h[i]<h[j]:
		pass
	else:
		h[i]-=1
	
	if h[i]>h[j]:
		f=False
		break
if f:
	print('Yes')
else:
	print('No')
n = int(input())
h = list(map(int, input().split()))

h_new = []

for i in range(n-1):
    if h[i] - h[i+1] >=1:
        h_new.append(h[i]-1)
    else:
        h_new.append(h[i])
h_new.append(h[-1])

cnt = 0
for i in range(n-1):
    if h_new[i+1] < h_new[i]:
        print('No')
        exit()
    else:
        cnt += 1

if cnt == len(h_new)-1:
    print('Yes')
import sys
n = int(input())
ls = list(map(int,input().split()))
mx = ls[0]
for i in range(n-1):
    if (ls[i+1] - ls[i]) == -1:
        ls[i] -= 1
        if ls[i] < mx:
            print("No")
            sys.exit()
        else:
            mx = ls[i]
    elif ls[i+1] - ls[i] <-1:
        print("No")
        sys.exit()
    else:
        if ls[i] > mx:
            mx = ls[i]
print("Yes")
input()
H = [int(i) for i in input().rstrip().split(' ')]
N = len(H)

for i in range(0,N):
    a = H[i]
    b = H[i - 1] if i > 0 else 0
    n = H[i + 1] if i < N -1 else 10**9
    #print(i,"#",b,a,n)
    if n == a - 1:
        if b == a:
            print("No")
            break
        else:
            H[i] -= 1
    elif n < a - 1:
            print("No")
            break
else:
    print("Yes")
def main():
    n = int(input())
    h = list(map(int, input().split()))

    pre = 0
    flag = True
    for i in range(n):
        if h[i] >= pre + 1:
            h[i] -= -1
        if h[i] < pre:
            flag = False
            break
        pre = h[i]
    
    if flag:
        print('Yes')
    else:
        print('No')
                

if __name__ == '__main__':
    main()
n = int(input())
h = list(map(int,input().split()))

for i in range(1,n-1):
    if h[i-1] <= h[i] <= h[i+1]:
        continue
    else:
        if h[i]>h[i+1]:
            h[i] -= 1
            if h[i]< h[i-1]:
                print('No')
                exit()

        if h[i] < h[i-1]:
            print('No')
            exit()


print('Yes')
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    if n == 1:
        print("No")
        return
    h = list(map(int, readline().rstrip().split()))
    for i in range(n - 1):
        right = h[n - i - 1]
        left = h[n - i - 2]
        if left == right + 1:
            h[n - i - 2] -= 1
        if left > right + 1:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()
N=int(input())
A=list(map(int, input().split()))
tmpmax=A[0]
ikeru=True
ok=True
for i in range(1,N):
  if tmpmax>A[i]:
    if tmpmax-1==A[i] and ok:
      tmpmax-=1
      ok=False
    else:
      ikeru=False
      break
  elif tmpmax==A[i] and ok==False:
    ikeru=False
    break
  else:
    ok=True
    tmpmax=A[i]

if ikeru:
  print("Yes")
else:
  print("No")
n = int(input())
h = list(map(int, input().split()))
for i in range(n - 1):
    if h[i + 1] - h[i] < -1:
        print("No")
        exit()
print("Yes")
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if A[i+1]-A[i] >= -1:
    if max(A[i],A[i+1]) >= ans:
      ans = max(A[i]-1,A[i+1]-1,ans)
      print(i)
    else:
      print('No')
      exit()
  else:
    print('No')
    exit()
print('Yes')
n = int(input())
li = list(map(int,input().split()))
ans = "Yes"
max_n = 0

if n == 1:
    print(ans)
else:
    for i in li:
        if i < max_n - 1:
            ans = "No"
            break
        else:
            max_n = max(i-1,max_n)
print(ans)
from collections import Counter
a = int(input())
num_list = list(map(int,input().split()))
flag = "ok"
num_o = 0
for i in range(a-1):
  if num_list[i] > num_o:
    num_o = num_list[i]-1
  if num_list[i]-num_list[i+1] > 1:
    flag = "ng"
    break

num_counter = Counter(num_list)
num_most = num_counter.most_common()
#if a == num_most[0][1] and a != 0:
#  flag = "No"
if flag == "ok":
  print("Yes")
else:
  print("No")
n=int(input());a=0
h=list(map(int,input().split()))
for i in reversed(range(n)):
    if h[i]<h[i-1]:
        if h[i]<h[i-1]-1:
            a="No"
            break
if a!=0 or n==1:
    print("Yes")
else:
    print("No")
s=input()
x=0
y=0
u=int(s[0:2])
d=int(s[2:])

if 1<=u and u<=12:
    x=1
else:
    x=-1
if 1<=d and d<=12:
    y=1
else:
    y=-1
    
if x*y==1 and x<0:
    print('NA')
elif x*y==1:
    print('AMBIGUOUS')
elif x==1 and y==-1:
    print('MMYY')
else:
    print('YYMM')
s = input()

a = int(s[:2])
b = int(s[2:])

if a <= 12 and a != 0:
  if b <= 12 and b != 0:
    print("AMBIGUOUS")
  elif b > 12 or b == 0:
    print("MMYY")
else:
  if b > 12 or b == 0:
    print("NA")
  elif b <= 12:
    print("YYMM")
S = input()
S1 = int(S[:2])
S2 = int(S[2:])

if 1<=S1<=12 and 1<=S2<=12:
    print('AMBIGUOUS')
elif 1<=S1<=12:
    print('MMYY')
elif 1<=S2<=12:
    print('YYMM')
else:
    print('NA')
S = input()
l, r =  map(int, [S[:2], S[2:]])

if 1 <= l <= 12 and 1 <= r <= 12:
  print("AMBIGUOUS")
elif 1 <= l <= 12 and (r == 0 or r > 12):
  print("MMYY")
elif (l == 0 or l > 12) and 1 <= r <= 12:
  print("YYMM")
else:
  print("NA")
S = input()
s01 = int(S[0]+S[1])
s23 = int(S[2]+S[3])
if (0 < s01 and s01 <= 12) and (0 < s23 and s23 <= 12):
    print('AMBIGUOUS')

elif (0 < s01 and s01 <= 12) and (s23 > 12 or s23 == 0):
    print('MMYY')

elif (s01 > 12 or s01 == 0) and (0 < s23 and s23 <= 12):
    print('YYMM')
else:
    print('NA')
S = input()

if int(S[:2]) == 0 and 0 < int(S[2:]) <= 12:
  print("YYMM")
elif int(S[2:]) == 0 and 0 < int(S[:2]) <= 12:
  print("MMYY")
elif int(S[:2]) == 0 or int(S[2:]) == 0 or (int(S[:2]) > 12 and int(S[2:]) > 12):
  print("NA")
elif int(S[:2]) > 12 and int(S[2:]) <= 12:
  print("YYMM")
elif int(S[:2]) <= 12 and int(S[2:]) > 12:
  print("MMYY")
else:
  print("AMBIGUOUS")
s = input()

a = int(s[:2])
b = int(s[2:])

if 0 <  a <= 12 and 0 < b <= 12:
  print("AMBIGUOUS")
elif (a > 12 or a == 0) and 0 < b <= 12:
  print("YYMM")
elif 0 < a <= 12 and (b > 12 or b == 0):
  print("MMYY")
else:
  print("NA")
S = input()
l = S[:2]
r = S[2:]
 
lcnt = 0
rcnt = 0
if 0 < int(l) <= 12:
    lcnt = 1
if  0 < int(r) <= 12:
    rcnt = 1
if lcnt and rcnt:
    print('AMBIGUOUS')
    exit()
elif lcnt:
    print('MMYY')
    exit()
elif rcnt:
    print('YYMM')
    exit()
else:
    print('NA')
s = input()
a = s[:2]
b = s[2:]
if int(a) == 0 or int(a) > 12:
	if int(b) == 0 or int(b) > 12:
		print("NA")
	else:
		print ("YYMM")
else:
	if int(b) == 0 or int(b) > 13:
		print ("MMYY")
	else:
		print ("AMBIGUOUS")
s = list(map(int,list(input())))
a = s[0]*10+s[1]
b = s[2]*10+s[3]
if a == 0 and b == 0:
    print('NA')
    exit()
if 0 < a<= 12 and (b>12 or b==0):
    print('MMYY')
elif (a > 12 or a==0) and 0 < b <= 12:
    print('YYMM')
elif a <= 12 and b <= 12:
    print('AMBIGUOUS')
else:print('NA')
x = int(input())
a = x // 100
b = x % 100

a_is_month = 0 < a & a <= 12
b_is_month = 0 < b & b <= 12

if a_is_month:
    if b_is_month:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b_is_month:
        print("YYMM")
    else:
        print("NA")
S = input()

A, B = int(S[:2]), int(S[2:])

x = 0 <= A <= 99 and 1 <= B <= 12
y = 1 <= A <= 12 and 0 <= B <= 99

if x and y:
    print('AMBIGUOUS')
elif x:
    print('YYMM')
elif y:
    print('MMYY')
else:
    print('NA')
S = input()
if 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12:
    print("AMBIGUOUS")
elif 1 <= int(S[2:]) <= 12:
    print("YYMM")
elif 1 <= int(S[:2]) <= 12:
    print("MMYY")
else:
    print("NA")
s = input()

forward = s[:2]
backward = s[2:]
def check(s):
    if 0<int(s)<=12:
        return True
    else:
        return False

if check(forward) and check(backward):
    print('AMBIGUOUS')
elif check(forward):
    print('MMYY')
elif check(backward):
    print('YYMM')
else:
    print('NA')
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    S = input()

    first = int(S[:2])
    second = int(S[2:])

    if 0 < first <= 12 and 0 < second <= 12:
        print('AMBIGUOUS')
    elif 0 < first <= 12:
        print('MMYY')
    elif 0 < second <= 12:
        print('YYMM')
    else:
        print('NA')


if __name__ == "__main__":
    main()
s = input()
x = int(s[:2])
y = int(s[2:])
if 1 <= x <= 12 and 1 <= y <= 12:
    a = "AMBIGUOUS"
elif 1 <= x <= 12:
    a = "MMYY"
elif 1 <= y <= 12:
    a = "YYMM"
else:
    a = "NA"
print(a)
N=input()

MM=0
mm=0


if int(N[0])>1 or (int(N[0])==1 and int(N[1])>2) or N[0:2]=="00":
    MM=0
else:
    MM=1
if int(int(N[2]))>1 or (int(N[2])==1 and int(N[3])>2 or N[2:4]=="00"):
    mm=0
else:
    mm=1

if MM+mm==2:
    print("AMBIGUOUS")
elif MM==1:
    print("MMYY")
elif mm==1:
    print("YYMM")
else:
    print("NA")
s=input()
cand=["0"+str(i) for i in range(1,10)]+["10","11","12"]
if s[:2] in cand and s[2:] in cand:
    print("AMBIGUOUS")
elif s[:2] in cand:
    print("MMYY")
elif s[2:] in cand:
    print("YYMM")
else:
    print("NA")
def YY(x):
    if 1<=x and x<=12:
        return True
    else:
        return False
S=input()
A=int(S[0:2])
B=int(S[2:4])
if YY(A) and YY(B):
    print("AMBIGUOUS")
elif YY(A):
    print("MMYY")
elif YY(B):
    print("YYMM")
else:
    print("NA")
s=input()
up=s[0:2]
bot=s[2:4]
bot_m=True
up_m=True
if bot == "00" or int(bot) > 12:
        bot_m=False
if up == "00" or int(up) > 12:
        up_m=False
if bot_m and up_m:
        print("AMBIGUOUS")
elif bot_m and not up_m:
        print("YYMM")
elif not bot_m and up_m:
        print("MMYY")
else:
        print("NA")
s=(input())
s1=int(s[:2])
s2=int(s[2:])
 
if 1<= s1 <=12 and 1<= s2 <= 12:
    print("AMBIGUOUS")
 
elif 0<= s1 <=99 and 1<= s2 <= 12:
    print("YYMM")
 
elif 1<= s1 <=12 and 0<= s2 <= 99:
    print("MMYY")
 
else:
    print("NA")
s=int(input())
a=s//100
b=s%100
if a>0 and a<=12:
  if b>0 and b<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if b>0 and b<=12:
    print("YYMM")
  else:
    print("NA")
s = input()

s1 = int(s[0])*10 + int(s[1])
s2 = int(s[2])*10 + int(s[3])
#print(s1, s2)
if  (s1>12 or s1==0) and (s2>12 or s2==0):
  print('NA')
elif (s1>12 or s1==0) and 1<=s2<=12:
  print('YYMM')
elif (s2>12 or s2==0) and 1<=s1<=12:
  print('MMYY')
elif 1<=s1<=12 and 1<=s2<=12:
  print('AMBIGUOUS')
from sys import exit
S = input()

if 0 < int(S[0:2]) < 13:
    if 0 < int(S[2:]) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < int(S[2:]) < 13:
        print("YYMM")
    else:
        print("NA")
s=input()

s1=s[0]+s[1]
s2=s[2]+s[3]

if (s1[0]=='0' and s1!='00') or s1=='11' or s1=='12':
  ans1='MM'
else:
  ans1='YY'

if (s2[0]=='0' and s2!='00') or s2=='11' or s2=='12':
  ans2='MM'
else:
  ans2='YY'

if ans1==ans2=='MM':
  print('AMBIGUOUS')
elif ans1==ans2=='YY':
  print('NA')
else:
  print(ans1+ans2)
s = input()
a,b = int(s[:2]),int(s[2:])

c = 0
if 1 <= a <= 12:
    c += 1
if 1 <= b <= 12:
    c += 2

print(['NA', 'MMYY', 'YYMM', 'AMBIGUOUS'][c])
S = input()
S_a = int(S[0] + S[1])
S_b = int(S[2] + S[3])
if((S_a >= 1 and S_a <= 12) and (S_b < 1 or S_b > 12)):
  print('MMYY')
elif((S_a < 1 or S_a > 12) and (S_b >= 1 and S_b <= 12)):
  print('YYMM')
elif((S_a >= 1 and S_a <= 12) and (S_b >= 1 and S_b <= 12)):
  print('AMBIGUOUS')
else:
  print('NA')
s=int(input())
s1=s//100
s2=s%100
if 12>=s1>=1 and 12>=s2>=1:
    ans="AMBIGUOUS"
elif 12>=s1>=1 and not 12>=s2>=1:
    ans="MMYY"
elif 12>=s2>=1 and not 12>=s1>=1:
    ans="YYMM"
else:
    ans="NA"
print(ans)
n=input()
if 1<=int(n[:2])<=12 and 1<=int(n[2:])<=12:
  print("AMBIGUOUS")
elif 1<=int(n[:2])<=12:
  print("MMYY")
elif 1<=int(n[2:])<=12:
  print("YYMM")
else:
  print("NA")
S=input()
a=int(S[:2])
b=int(S[2:])
if 1<=a<=12 and 1<=b<=12:
    print("AMBIGUOUS")
elif 1<=a<=12 and (b>=13 or b==0):
    print("MMYY")
elif a>=13 and (b>=13 or b==0):
    print("NA")
elif a>=13 and 1<=b<=12:
    print("YYMM")
elif a==0 and (b>=13 or b==0):
    print("NA")
elif a==0 and (1<=b<=12):
    print("YYMM")
S = input()

if 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
    print('AMBIGUOUS')
    exit()
elif 0 < int(S[:2]) <= 12:
    print('MMYY')
    exit()
elif 0 < int(S[2:]) <= 12:
    print('YYMM')
    exit()
else:
    print('NA')
    exit()
s=str(input())
a="Y"
b="Y"
if 0<int(s[0:2])<13:
    a="MY"
if 0<int(s[2:5])<13:
    b="MY"

if a==b=="Y":
    ans="NA"
elif a=="Y" and b=="MY":
    ans="YYMM"
elif a=="MY" and b=="Y":
    ans="MMYY"
else:
    ans="AMBIGUOUS"
print(ans)
S=input()
x=int(S[:2])
y=int(S[2:4])
if 1<=x<=12:
    if 1<=y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=y<=12:
        print("YYMM")
    else:
        print("NA")
s=input()
a=int(s[0:2])
b=int(s[2:4])
if 0<a<13:
  if 0<b<13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<b<13:
    print('YYMM')
  else:
    print('NA')
s = input()
if    1 <=int(s[0:2]) <= 12 and 1<= int(s[2:4]) <= 12:
    print("AMBIGUOUS")
elif  1<= int(s[2:4]) <= 12:
    print("YYMM")
elif  1<= int(s[0:2]) <= 12:
    print("MMYY")
else :
    print("NA")
s = input()
if (int(s[:2]) >= 13 or s[:2] == '00') and (int(s[2:4]) >= 13 or s[2:4] == '00'):
    print('NA')
elif 0 < int(s[:2]) <= 12 and 0 < int(s[2:4]) <= 12:
    print('AMBIGUOUS')
elif 0 < int(s[:2]) <= 12:
    print('MMYY')
else:
    print('YYMM')
def check_month(month):
    return 1 <= int(month) <= 12

S = input()

ls = S[:2]
rs = S[2:]

if check_month(ls) and check_month(rs):
    print('AMBIGUOUS')
elif check_month(ls) and not check_month(rs):
    print('MMYY')
elif not check_month(ls) and check_month(rs):
    print('YYMM')
else:
    print('NA')
S = int(input())

A = S//100
B = S%100

if A >= 13 or A == 0:
    if B >= 13:
        print('NA')
    elif B <13:
        if B != 0:
            print('YYMM') 
        else:
            print('NA')
elif A < 13:
    if B >= 13:
            print('MMYY')
    elif B < 13:
        if B != 0:
            print('AMBIGUOUS')
        else:
            print('MMYY')
S = input()
f = int(S[:2])
b = int(S[2:])
if (not 0 < f <= 12) and 0 < b <= 12:
    print('YYMM')
elif (not 0 < b <= 12) and 0 < f <= 12:
    print('MMYY')
elif 0 < f <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
# B - YYMM or MMYY

s = str(input()) # 長さ４の数字列

def check(n):
    if n > 0 and n <= 12:
        return True
    else:
        return False

mae = check(int(s[0:2]))
ato = check(int(s[2:4]))

if mae and ato:
    print('AMBIGUOUS')
elif mae and not ato:
    print('MMYY')
elif not mae and ato:
    print('YYMM')
else:
    print('NA')
s = input()
if (1 <= int(s[0:2]) and int(s[0:2]) <= 12) and (1 <= int(s[2:4]) and int(s[2:4]) <= 12):
    ans = "AMBIGUOUS"
elif (1 <= int(s[0:2]) and int(s[0:2]) <= 12) and (1 > int(s[2:4]) or int(s[2:4]) > 12):
    ans = "MMYY"
elif (1 > int(s[0:2]) or int(s[0:2]) > 12) and (1 <= int(s[2:4]) and int(s[2:4]) <= 12):
    ans = "YYMM"
else:
    ans = "NA"
print (ans)
S = input()
p = int(S[0:2])
s = int(S[2:4])

if 1 <= p and p <= 12:#?
    if 1<= s and s<=12:#??
        print("AMBIGUOUS")
    else:#?Y
        print("MMYY")

else:
    if 1<= s and s<=12:#Y?
        print("YYMM")
    else:#YY
        print("NA")
s = input()

xx = s[0] + s[1]
yy = s[2] + s[3]
xx = int(xx)
yy = int(yy)

if 1 <= xx <= 12:
    if yy >= 13 or yy == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

if xx == 0 or 13 <= xx <= 99:
    if 1 <= yy <= 12:
        print("YYMM")
    else:
        print("NA")
s = input()
a = 0
b = 0

if s[2] == '0': b = int(s[3])
else: b = int(s[2:])
if s[0] == '0': a = int(s[1])
else: a = int(s[:2])

if (b>=1 and b<=12) and (a>=1 and a<=12): print("AMBIGUOUS")
elif b>=1 and b<=12: print("YYMM")
elif a>=1 and a<=12: print("MMYY")
else: print("NA")