peterverebics/CodeNet_Python_118 huggingface dataset:
s = input()
YYMM, MMYY, ova = False, False, False

if(1 <= int(s[:2]) <= 12 and int(s[3:]) != 0):
    MMYY = True
if(1 <= int(s[3:]) <= 12 and int(s[:2]) != 0):
    YYMM = True

if(MMYY and YYMM):
    ova = True

if(ova):
    print('AMBIGUOUS')
elif(MMYY):
    print("MMYY")
elif(YYMM):
    print('YYMM')
else:
    print('NA')
S = input()
S1, S2 = S[0:2], S[2:5]
if int(S1) > 12:
	print('YYMM')
elif int(S2) > 12:
	print('MMYY')
else:
	print('AMBIGUOUS')
s = input()

if int(s[:2]) <= 12 and int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif int(s[2:]) > 13 and s[:2] != '00':
    print('MMYY')
elif int(s[:2]) > 13 and s[2:] != '00':
    print('YYMM')
else:
    print('NA')
s=input()

def month(n):
    if n <= 12:
        return True
    else:
        return False
if s == "0000":
    print("NA")
    exit()

if month(int(s[0:2])):
    if month(int(s[2:4])) and int(s[2:4]) != 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if month(int(s[2:4])) and int(s[2:4]) != 0:
            print("YYMM")
    else:
        print("NA")
s = int(input())
s_1 = s // 100 #4桁の数字列の上2桁を取り出す
s_2 = s % 100  #4桁の数字列の下2桁を取り出す

if 1 <= s_1 <=12 and 1 <= s_2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s_1 <= 12 and s_2 > 12:
    print("MMYY")
elif 1 <= s_2 <= 12 and s_1 > 12:
    print("YYMM")
else:
    print("NA")
S = input()

#print(int(S[:2]), int(S[2:]))

if S[2:] == '00' or S[:2] == '00':
    print('NA')
elif int(S[:2]) <= 12 and int(S[2:]) > 12:
    print('MMYY')
elif int(S[:2]) > 12 and int(S[2:]) <= 12:
    print('YYMM')
else:
    print('AMBIGUOUS')
import sys
import math

s=input()

if (s[2]=="1" and (s[3]=="1" or s[3]=="2" or s[3]=="0")) or s[2]=="0":
	if (s[0]=="1" and (s[1]=="1" or s[1]=="2" or s[1]=="0") or s[0]=="0"):
		print("AMBIGUOUS")
		sys.exit()
	print("YYMM")
	sys.exit()

else:
	if (s[0]=="1" and (s[1]=="1" or s[1]=="2" or s[1]=="0") or s[2]=="0"):
		print("YYMM")
		sys.exit()
print("NA")
s = input()

s_u, s_l = int(s[:2]), int(s[2:])
if s_u != 0 and 1 <= s_l <= 12:
    print('YYMM')
elif 1 <= s_u <= 12 and s_l != 0:
    print('MMYY')
elif 1 <= s_u <= 12 and 1 <= s_l <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
S = list(input())
before = int(S[0] + S[1])
after = int(S[2] + S[3])

if before == 0 or before > 12:
    if after >= 1 and after <= 12:
        print('YYMM')
    else:
        print('NA')
else:
    if after >= 1 and after <= 12:
        print('AMBIGUOS')
    else:
        print('MMYY')
S = input()
ff = int(S[:2])
ll = int(S[2:])
if 0<ff<=12 and 0<ll<=12:
    print("AMBIGUOUS")
elif ff>12 and 0<ll<=12:
    print("YYMM")
elif 0<ff<=12 and ll>12:
    print("MMYY")
else:
    print("NA")
S = input()
ff = int(S[:2])
ll = int(S[3:])
if 0<ff<=12 and 0<ll<=12:
    print("AMBIGUOUS")
elif ff>12 and 0<ll<=12:
    print("YYMM")
elif 0<ff<=12 and ll>12:
    print("MMYY")
else:
    print("NA")
s=list(input())
s=list(map(int,s))

a=s[0]*10+s[1]
b=s[2]*10+s[3]

if (a==0 and b==0) or (a>=13 and b>=13) or (a==0 or b>=13) or (a>=13 or b==0):
  print("NA")
elif 0<a<=12 and 0<b<=12:
  print("AMBIGUOUS")
elif 0<a<=12:
  print("MMYY")
else:
  print("YYMM")
S = str(input())

flag = [0, 0] # [YYMM, MMYY]
l = 10*int(S[0]) + int(S[1])
r = 10*int(S[2]) + int(S[3])
if (1<=l and l<=99) and (1<=r and r<=12):
  flag[0] += 1
if (1<=l and l<=12) and (1<=r and r<=99):
  flag[1] += 1
if flag == [0, 0]:
  print('NA')
elif flag == [0, 1]:
  print('MMYY')
elif flag == [1, 0]:
  print('YYMM')
else:
  print("AMBIGUOUS")
s = input()
if 1 <=int(s[0:2]) <= 12 and 1<= int(s[2:4]) <= 12:
    print("AMBIGUOUS")
elif (int(s[0:2]) == 0 or 13 <=int(s[0:2]) <= 99) and 1<= int(s[2:4]) <= 12:
    print("YYMM")
elif (int(s[2:4]) == 0 or 13 <=int(s[0:2]) <= 99) and 1<= int(s[0:2]) <= 12:
    print("MMYY")
else :
    print("NA")
S = input()

f = S[:3]
s = S[3:]

if 1<=int(f)<=12:
    if 1<=int(s)<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=int(s)<=12:
        print("YYMM")
    else:
        print("NA")
S = input()

if S[:2] == '00' and int(S[2:]) > 12:
    print('NA')
elif S[2:] == '00' and int(S[:2]) > 12:
    print('NA')
elif S == '0000':
    print('NA')
elif int(S[:2]) <= 12 and int(S[2:]) <= 12:
    print('AMBIGUOUS')
elif int(S[:2]) <= 12:
    print('MMYY')
elif int(S[2:]) <= 12:
    print('YYMM')
else:
    print('NA')
s = input()

a = int(s[0] + s[1])
b = int(s[2] + s[3])

if 13 <= a and 1 <= b <= 12:
    print('YYMM')
elif 1 <= a <= 12 and 13 <= b:
    print('MMYY')
elif 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
s = input()
mmyy = (1 <= int(s[0:2]) <= 12)
yymm = (1 <= int(s[2:-1]) <= 12)
if mmyy:
  if yymm:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if yymm:
    print('YYMM')
  else:
    print('NA')
def main():
    S = input()
    if int(S[:2]) > 12 and 12 >= int(S[3:]) > 0:
        print("YYMM")
    elif int(S[3:]) > 12 and 12 >= int(S[:2]) > 0:
        print("MMYY")
    elif 0 < int(S[:2]) <= 12 and 0 < int(S[3:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("NA")


if __name__ == '__main__':
    main()
S = input()
Fa = int(S[:2])
Se = int(S[2:])
if 1 <= Fa <= 12 and 1 <= Se <= 12:
	print("AMBIGIOUS")
elif 1 <= Fa <= 12:
	print("MMYY")
elif 1 <= Se <= 12:
	print("YYMM")
else:
	print("NA")
s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
if s1 == s2 == 0:
    print('NA')
elif s1 <= 12:
    if s2 <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif s2 <= 12:
    if s1 <= 12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    print('NA')
s = input()
mae = int(s[:2])
ato = int(s[3:])

if mae<=12 and ato<=12 and mae>0 and ato>0:
    print('AMBIGUOUS')
elif 12<ato and mae>0:
    print('MMYY')
elif 12<mae and ato>0:
    print('YYMM')
else:
    print('NA')
a=input()
a_i=int(a[0:2])
b_i=int(a[2:4])
if a_i<=12 and b_i<=12:
    print('AMBIGUOUS')
elif 0<b_i<=12:
    print("YYMM")
elif 0<a_i<=12:
    print("MMYY")
else:
    print("NA")
s=input()
f=int(s[:2])
b=int(s[2:4])

if (f>=13 or f==00)and b>=13 :
    print('NA')
elif (f>=13 or f==00)and 1<=b<=12 :
    print('YYMM')
elif 1<=f<=12 and (b>=13 or b==00) :
    print('MMYY')
elif f<=13 and (b>=13 or b==00) :
    print('AMBIGUOUS')
s = list(map(int,list(input())))
a = s[0]*10+s[1]
b = s[2]*10+s[3]
if 0 < a <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
elif 0 < a<= 12 and b>12:
    print('MMYY')
elif a > 12 and 0 < b <= 12:
    print('YYMM')
else:print('NA')
S = input()
a = int(S[:2])
b = int(S[2:])

ym = False
my = False
if a > 0 and b>0 and b <= 12:
  ym = True
if b > 0 and a>0 and a <= 12:
  my = True

if ym and my:
  print("AMBIGOUS")
elif ym and not(my):
  print('YYMM')
elif not(ym) and ym:
  print('MMYY')
else:
  print('NA')
s = input()
YYMM = False
MMYY = False

if 0 < int(s[:2]) < 100:
    if 0 < int(s[2:]) < 13:
        YYMM = True
if 0 < int(s[:2]) < 13:
    if 0 < int(s[2:]) < 100:
        MMYY = True
if YYMM == True and MMYY == True:
    print('AMBIGUOUS')
elif YYMM == True:
    print('YYMM')
elif MMYY == True:
    print('MMYY')
else:
    print('NA')
s = input()

first = s[:2]
second = s[2:]

if int(first) > 12:
    first_m = False
else:
    first_m = True

if int(second) > 12:
    second_m = False
else:
    second_m = True

if first == "00" and not second_m:
    print("NA")
elif second == "00" and not first_m:
    print("NA")
elif first_m and second_m:
    print("AMBIGUOUS")
elif first_m:
    print("MMYY")
elif second_m:
    print("YYMM")
else:
    print("NA")
S = list(input())

fo = int(''.join(S[:2]))
la = int(''.join(S[2:]))

if fo==0 or la==0:
  print("NA")
elif fo <= 12 and la <= 12:
  print("AMBIGUOUS")
elif fo <= 12 and la > 12:
  print("MMYY")
elif fo > 12 and la <= 12:
  print("YYMM")
elif fo > 12 and la > 12:
  print("NA")
n = list(map(str,input().split()))
if int(n[0][0:2]) in range(13,100) and int(n[0][3]) in range(1,13):
  print('YYMM')
elif int(n[0][1]) in range(1,13) and int(n[0][2:]) in range(13,100):
  print('MMYY')
elif int(n[0][0:2]) in range(1,13) and int(n[0][2:]) in range(1,13):
  print('AMBIGUOUS')
else:
  print('NA')
S = input()

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

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

if x and y:
    print('AMBIGUOUS')
elif x:
    print('YYMM')
elif y:
    print('MMYY')
else:
    print('NA')
n=input()

m=n[0]+n[1]

o=n[2]+n[3]

x=int(m)
y=int(o)

if x>0 and x<13 and y>0 and y<13:
    print("AMBIGUOUS")

elif (x<13 and x>0) and (y>12):
    print("MMYY")
elif (x>12) and (y<13 and y>0):
    print("YYMM")

elif x==0 or y==0:
    print("NA")
S = input()
ff = int(S[:2])
ll = int(S[2:])
if 0<ff<=12 and 0<ll<=12:
    print("AMBIGUOUS")
elif ff == 0 or ff>12 and 0<ll<=12:
    print("YYMM")
elif 0<ff<=12 and ll>12 or ll== 0:
    print("MMYY")
else:
    print("NA")
s = [int(k) for k in list(input())]
s1 = 10*int(s[0])+int(s[1])
s2 = 10*int(s[2])+int(s[3])
if s2 == 0 and s1 > 12:
    print("NA")
elif s1 > 12 and s2 <= 12:
    print("YYMM")
elif s1 <= 12 and s2 > 12:
    print("MMYY")
else:
    if s1 > 12 and s2 > 12:
        print("NA")
    else:
        print("AMBIGUOUS")
def resolve():
    S = input()
    P = int(S[0]+S[1])
    Q = int(S[2]+S[3])
    if 00<P<=12 and 00<Q<=12:
        print("AMBIGUOUS")
    elif 00<P<=12 and Q>12:
        print("MMYY")
    elif P>13 and 00<Q<=12:
        print("YYMM")
    else:
        print("NA")
resolve()
s = list(str(input()))

x = int(s[0] + s[1])
y = int(s[2] + s[3])

if 13 <= x and (1 <= y and y <= 12):
    print('YYMM')
elif (1 <= x and x <= 12) and 13 <= y:
    print('MMYY')
elif (1 <= x and x <= 12) and (1 <= y and y <= 12):
    print('AMBIGUOUS')
else:
    print('NA')
S = list(input())

head = int("".join(S[:2]))
tale = int("".join(S[2:]))

if 0 == head or head > 12:
    # YYMM
    if 0 == tale or tale > 12:
        print("NA")
    else:
        print("YYMM")

elif 0 == tale or tale > 12:
    print("AMBIGUOUS")
else:
    print("AMBIGUOUS")
x = input()
a, b = int(x[0:2]), int(x[2:4])
flag = 0
ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"]

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0):
    flag = 3
elif ((a > 0 and a <= 12) and (b >= 13)) or (a == 0 and (b >= 1 and b <= 12)):
    flag = 2
elif ((a >= 13) and (b > 0 and b <= 12)) or (b == 0 and (a >= 1 and a <= 12)):
    flag = 1


print(ans[flag])
S = input()
year_list = ["01","02","03","04","04","05","06","07","08","09","10","11","12"]

if S[0:2] in year_list:
    if S[2:4] in year_list:
        print("AMBIGUOUS")
    elif S[2:4] == "00":
        print("NA")
    else:
        print("YYMM")
elif S[0:2] == "00":
    print("NA")
else:
    if S[2:4] in year_list:
        print("MMYY")
    else:
        print("NA")
S=input()
a=int(S[:2]); b=int(S[2:])
if (0<a and a<13) and (0<b and b<13): print('AMGIGUOUS')
elif (0<a and a<13) and 0<b: print('MMYY')
elif 0<a and (0<b and b<13): print('YYMM')
else: print('NA')
S = input()
first = int(S[:2])
last = int(S[2:])
print(first, last)

is_month_first = False
is_month_last = False

if first <= 12 and first > 0:
    is_month_first = True
if last <= 12 and last > 0:
    is_month_last = True

if is_month_first and is_month_last:
    print("AMBIGUOUS")
elif not is_month_first and not is_month_last:
    print("NA")
else:
    if is_month_first:
        print("MMYY")
    else:
        print("YYMM")
s = input()
a = int(s[0:2])
b = int(s[2:])

if 13 <= a:
    if 1 <= b and b <= 12:
        print('YYMM')
    else:
        print('NA')
elif 1<= a:
    
    if 1<= b  and b<= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<= b and b <= 12:
        print('MMYY')
    else:
        print('NA')
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    S = input()

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

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


if __name__ == "__main__":
    main()
s=input()

first_two=int(''.join(s[:2]))
last_two=int(''.join(s[2:]))

if 13<=first_two and 1<=last_two<=12:
  print('YYMM')
elif 13<=last_two and 1<=first_two<=12:
  print('MMYY')
elif 1<=first_two<=12 and 1<=last_two<=12:
  print('AMBIGUOUS')
else:
  print('NA')
s = input()

#s = list(s)

mae = int(s[:2])
usi = int(s[2:])
#print(mae,usi)


if(mae >= 1 and mae <= 12 and usi >= 1 and usi <= 12):
  print("AMBIGUOUS")
elif(mae == 0 and usi == 0):
  print("NA")
elif(mae == 0 and usi >= 12):
  print("NA")
elif(mae >= 12 and usi == 0):
  print("NA")
elif(mae >= 0 and mae <= 99 and usi >= 1 and usi <= 12):
  print("YYMM")
elif(usi >= 0 and usi <= 99 and mae >= 1 and mae <= 12):
  print("MMYY")
s = int(input())
a = s % 100
b = ((s-a) % 100)
if a <= 31 and b <= 12:
  print("YYMM")
elif a <= 12 and b <= 31:
  print("MMYY")
elif  a <= 12 and b <= 31 and a <= 31 and b <= 12:
  print("AMBIGUOUS")
else:
  print("NA")
a = input()
b = a[0:2]
c = a[2:4]
if b.count("0") >= 1:
    print(b.strip("0"))
else:
    print(b)
if c.count("0") >= 1:
    print(c.strip("0"))
else:
    print(c)
b = int(b)
c = int(c)
if b > 12:
    if c > 12:
        print("NA")
    else:
        print("MMYY")
elif c > 12:
    if b < 13:
        print("YYMM")
else:
    print("AMBIGUOUS")
S = input()
l,r = int(S[:2]),int(S[2:])
if 1 <= l <= 12 and 1 <= r <= 12:
	print("AMBICIOUS")
elif 1<=r<=12:
	print("YYMM")
elif 1<=l<=12:
	print("MMYY")
else:
	print("NA")
s=input()
s1=int(s[0]+s[1])
s2=int(s[2]+s[3])
if (0<s1<13)and(0<s2<13):
    print("AMBIGUOUS")
elif (0<s1<13)and(s2!=0):
    print("MMYY")
elif (s1!=0)and(0<s2<13):
    print("YYMM")
else:
    print("NA")
S =list(input())

former = int(S[0])*10+int(S[1])
latter = int(S[2])*10+int(S[3])
former_YY=False
former_MM=False
latter_YY=False
latter_MM=False

if former <= 99 and former != 0:
    former_YY = True
    
if former <= 12 and former != 0:
    former_MM = True

if latter <= 99 and latter != 0:
    latter_YY = True

if latter <= 12 and latter != 0:
    latter_MM = True

if former_YY and former_MM and latter_YY and latter_MM:
    print("AMBIGUOUS")
elif former_YY and latter_MM:
    print("YYMM")
elif former_MM and latter_YY:
    print("MMYY")
else:
    print("NA")
S = input()

former = S[:2]
later = S[2:]

if int(later) == 0 or int(former) == 0:
    print('NA')
elif int(former) < 13 and int(later) < 13:
    print('AMBIGUOUS')
elif int(former) > 12 and int(later) < 13:
    print('YYMM')
elif int(former) < 13 and int(later) > 12:
    print('MMYY')
else:
    print('NA')
S=input()

if int(S[:2])>12 and 0<int(S[2:])<=12:
    print("YYMM")
elif 0<int(S[:2])<=12 and int(S[2:])>12:
    print("MMYY")
elif 0<int(S[:2])<=12 and 0<int(S[2:])<=12:
    print("AMBIGUOUS")
else:
    print("NA")
S = list(input())
f1 = 1
f2 = 1
A = int(''.join(S[:2]))
B = int(''.join(S[2:]))
print(A,B)
if A >= 13 or A == 0:
    f1 = 0
if B >= 13 or B == 0:
    f2 = 0
if f1 == 1 and f2 == 1:
    print('AMBIGUOUS')
elif f1 == 1 and f2 == 0:
    print('MMYY')
elif f1 == 0 and f2 == 1:
    print('YYMM')
else:
    print('NA')
s = input()

if s[:2] == "00" and s[2:] == "00":
  print("NA")
  exit()

if int(s[:2]) >= 13 and int(s[2:]) >= 13:
  print("NA")
  exit()

if 1 <= int(s[:2]) <= 12 and 1 <= int(s[2:]) <= 12:
  print("AMBIGUOUS")
  exit()


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

if (f>=13 or f==00)and b>=13 :
    print('NA')
if (f>=13 or f==00)and 1<=b<=12 :
    print('YYMM')
elif 1<=f<=12 and (b>=13 or b==00) :
    print('MMYY')
if f<=13 and (b>=13 or b==00) :
    print('AMBIGUOUS')
S = input()
Y = int(S[:2])
M = int(S[2:])
print(''.join(['NA' if Y == 0 or M == 0 else 'AMBIGUOUS' if Y <= 12 and M <= 12 else 'YYMM' if Y > 12 else 'MMYY']))
# input
S = input()
x, y = S[:2], S[2:]

# check
not_YY_x = (int(x) >= 13)
not_YY_y = (int(y) >= 13)
zero_x = (x == "00")
zero_y = (y == "00")
checker = [not_YY_x, not_YY_y, zero_x, zero_y]

if checker == [True, False, False, False] or checker == [True, False, False, True]:
    print("YYMM")
elif checker == [False, True, False, False] or checker == [False, True, True, False]:
    print("MMYY")
elif checker == [False, False, False, False]:
    print("AMBIGUOUS")
else:
    print("NA")
S = str(input())

S1 = S[0:2]
S2 = S[2:4]

if 1 <= int(S1) <= 12:
    if 1 <= int(S2) <= 12:
        print('AMBIGOUS')
        exit()
    else:
        print('MMYY')
        exit()
elif 1 <= int(S2) <= 12:
    print('YYMM')
else:
    print('NA')
import sys

S =int(input())
a = S//100
b = S%100
if 1 <= a <= 12 and 1 <= b <= 12 :
    print("AMBIGUOUS")
    sys.exit()

elif 1 <= a <= 12 :
    print("YYMM")
    sys.exit()

elif 1 <= b <= 12 :
    print("MMYY")
    sys.exit()
else : print("NA")
s = str(input())
a = int(s[0])*10 + int(s[1])
b = int(s[2])*10 + int(s[3])
if a >= 13 and 1 <= b <= 12:
    print("YYMM")
elif 1 <= a <= 12 and b >= 13:
    print("MMYY")
elif 1 <= a <= 12 and 1 <= b <= 12:
    print("ABIGUOUS")
else:
    print("NA")
s=list(input())
a=int("".join(s[:2]))
b=int("".join(s[2:]))
print("NA" if a == 0 or b == 0 else 
      "NA" if a >= 13 and b >= 13 else 
      "YYMM" if a > 12 else 
      "MMYY" if b > 12 else 
      "AMBIGUOUS")
s = input()
a=int(s[0:2])
b=int(s[2:4])
if 0<b<=12:
    print('YYMM')
elif 0<a<=12 :
    print('MMYY')
elif 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
else:
    print('NA')
def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13 and (front > 0 or latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA')
main()
# input
S = input()
x, y = S[:2], S[2:]

# check
not_YY_x = (int(x) >= 13)
not_YY_y = (int(y) >= 13)
zero_x = (x == "00")
zero_y = (y == "00")
checker = [not_YY_x, not_YY_y, zero_x, zero_y]

if checker == [True, False, False, False]:
    print("MMYY")
elif checker == [False, True, False, False]:
    print("YYMM")
elif checker == [False, False, False, False]:
    print("AMBIGUOUS")
else:
    print("NA")
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    if S[:2] == '00' or S[2:] == '00': print('NA')
    elif int(S[:2]) <= 12 and int(S[2:]) > 12: print('MMYY')
    elif int(S[:2]) > 12 and int(S[2:]) <= 12: print('YYMM')
    elif int(S[:2]) <= 12 and int(S[2:]) <= 12: print('AMBIGUOUS')
    else: print('NA')

if __name__ == '__main__':
    main()
S = list(input())

S1 = int(S[0]+S[1])
S2 = int(S[2]+S[3])
#print(S1,S2)
if((S1 == 0 or S2 == 0) or (S1 > 12 and S2 > 12)):
    print('NA')
elif(S1 < 13 and S2 < 13):
    print('AMBIGUOUS')
elif(S1 < 13):
    print('MMYY')
else:
    print('YYMM')
s = input()
t = int(s[:2])
tt = int(s[2:])
if t <= 12 and tt <= 12:
  print("AMBIGUOUS")
elif t > 12 and tt <= 12 and tt >= 1:
  print("YYMM")
elif t <= 12 and tt > 12 and t >= 1:
  print("MMYY")
else:
  print("NA")
s = input()
sa = int(s[:2])
sb = int(s[3:])

if sa >= 1 and sa <= 12 and sb >= 1 and  sb <= 12:
    print('AMBIGUOUS')
    exit()
if sa >= 1 and sa <= 12 and sb > 12:
    print('MMYY')
    exit()
if sa > 12 and sb >= 1 and sb <= 12:
    print('YYMM')
    exit()

print('NA')
s=input()
s1=int(s[0]+s[1])
s2=int(s[2]+s[3])
ans=""
if s1>12 or s1<=0:
	if s2>12 or s2<=0:
		ans="NA"
	else:
		ans="YYMM"
else:
	if s2>12:
		ans="MMYY"
	else:
		ans="AMBIGUOUS"

print(ans)
S = input()
high = int(S[0:2])
low = int(S[2:4])

if 1<= high <= 12:
    if 1<= low <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
if high < 1 or high > 12:
    if 1<= low <= 12:
        print("YYMM")
    else:
        print("AMBIGUOUS")
S=input()
a=int(S[:2]); b=int(S[2:])
if 0<a and 0<b:
    if a<13 and b<13:
        print('AMBIGUOUS')
    elif a<13:
        print('MMYY')
    elif b<13:
        print('YYMM')
    else:
        print('NA')
else: print('NA')
s = input()
#print(s[2])
print(int(s[0] + s[1]))

if int(s[0] + s[1])>12 and 0<int(s[0] + s[1])<=12 and int(s[2] + s[3])<=12:
    print("YYMM")
elif int(s[0] + s[1])<=12 and int(s[2] + s[3])<=12 and int(s[0] + s[1])>0 and int(s[2] + s[3])>0:
    print("AMBIGUOUS")
elif int(s[0] + s[1])>0 and int(s[0] + s[1])<=12 and int(s[2] + s[3])>12:
    print("MMYY")
else:
    print("NA")
s = input()
if s == '0000' or (int(s[:2]) >= 13 and int(s[-2:]) >= 13):
    print('NA')
elif 1 <= int(s[:2]) <= 12 and 1 <= int(s[-2:]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(s[:2]) <= 12:
    print('MMYY')
elif 1 <= int(s[-2:]) <= 12:
    print('YYMM')
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 12<b:
	print("MMYY")
elif 12<a and 1<=b<=12:
	print("YYMM")
else:
	print("NA")
s = list(input())
ab = int(s[0]+s[1])
cd = int(s[2]+s[3])
ans = ""
if 1 <= ab <= 12 and (cd == 0 or 13 <= cd):
    ans = "MMYY"
elif 1 <= cd <= 12 and (ab == 0 or 13 <= ab):
    ans = "YYNN"
elif 1 <= ab <= 12 and 1 <= cd <= 12:
    ans = "AMBIGUOUS"
else:
    ans = "NA"
print(ans)
S = input()
first = int(S[:2])
second = int(S[2:])

def month(num):
  if first <= 12:
    return True
  else:
    return False

if month(first) and month(second):
  print('AMBIGUOUS')

elif month(first) and month(second) == False:
  print('MMYY')

elif month(first) == False and month(second):
  print('YYMM')

else:
  print('NA')
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    if S[:2] == '00' or S[2:] == '00': print('NA')
    elif int(S[:2]) <= 12 and int(S[2:]) > 12: print('MMYY')
    elif int(S[:2]) > 12 and int(S[2:]) <= 12: print('YYMM')
    else: print('AMBIGUOUS')

if __name__ == '__main__':
    main()
S = input()
a = int(S[0])
b = int(S[1])
c = int(S[2])
d = int(S[3])

if a*10 + b == 0:
    if c*10 + d == 0:
        print("NA")
    elif c*10 + d <= 12:
        print("YYMM")
    else:
        print("NA")
elif a*10 + b <= 12:
    if c*10 + d <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if c*10 + d == 0:
        print("NA")
    elif c*10 + d <= 12:
        print("YYMM")
    else:
        print("NA")
S = list(map(int, input()))

if 0<S[0]*10+S[1]<=12 and 0<S[2]*10+S[3]<=12:
    print('AMBIGUOUS')
elif 0<S[0]*10+S[1]<=12 and S[2]*10+S[3]>=13:
    print('MMYY')
elif 0<S[2]*10+S[3]<=12 and S[0]*10+S[1]>=13:
    print('YYMM')
else:
    print('NA')
s = input()

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

if a == 0 or b == 0:
  print("NA")
elif a > 12 and b <= 12:
  print("YYMM")
elif a <= 12 and b > 12:
  print("MMYY")
elif a <= 12 and b <= 12: 
  print("AMBIGUOUS")
else:
  print("NA")
s=input()
a=int(s[0:2])
b=int(s[2:])
if 1<=a<=99 and 1<=b<=31:
    if 1<=a<=12 and 1<=b<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
elif 1<=b<=99 and 1<=a<=12:
    print('MMYY')
else:
    print('NA')
s=input()

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

former = S[:2]
later = S[2:]

if int(later) == 0 or int(former) == 0:
    print('NA')
elif int(former) > 12 and int(later) < 13:
    print('YYMM')
elif int(former) < 13 and int(later) > 12:
    print('MMYY')
elif int(former) < 13 and int(later) < 13:
    print('AMBIGUOUS')
else:
    print('NA')
s = [int(k) for k in list(input())]
s1 = 10*int(s[0])+int(s[1])
s2 = 10*int(s[2])+int(s[3])
if s2 == 0:
    print("NA")
elif s1 <= 12 and s2 <= 12:
    print("AMBIGUOUS")
elif s1 <= 12 and s2 >= 12:
    print("MMYY") 
else:
    print("YYMM")
S = input()
pre, lat = int(S[0:2]), int(S[2:4])
pre_M = 1 <= pre <= 12
lat_M = 1 <= pre <= 12
if pre_M and lat_M:
  print("AMBIGUOUS")
elif pre_M:
  print("MMYY")
elif lat_M:
  print("YYMM")
else:
  print("NA")
S = input()
F = int(S[0:2])
SE = int(S[2:4])

if F > 12 and SE > 12:
  print("NA")
elif F > 12 and 1 <= SE <= 12:
  print("YYMM")
elif 1 <= F <= 12 and SE > 12:
  print("MMYY")
elif 1 <= F <= 12 and 1 <= SE <= 12:
  print("AMBIGUOUS")
elif F == 0 and SE == 0:
  print("NA")
else:
  print("NA")