s=input()
s_front=int(s[0]+s[1])
s_end=int(s[2]+s[3])

def MM(x):
    if 1<=x<=12:return True
    else:return False

if MM(s_front) and MM(s_end):print("AMBIGUOUS")
elif MM(s_front) and not MM(s_end):print("MMYY")
elif not MM(s_front) and MM(s_end):print("YYMM")
else:print("NA") s=input() s input() input s_front=int(s[0]+s[1]) s_front int(s[0]+s[1]) int s[0]+s[1] s[0] s 0 s[1] s 1 s_end=int(s[2]+s[3]) s_end int(s[2]+s[3]) int s[2]+s[3] s[2] s 2 s[3] s 3 def MM(x):
    if 1<=x<=12:return True
    else:return False MM if 1<=x<=12:return True
    else:return False 1<=x<=12 1<=x 1 x 12 x x if MM(s_front) and MM(s_end):print("AMBIGUOUS")
elif MM(s_front) and not MM(s_end):print("MMYY")
elif not MM(s_front) and MM(s_end):print("YYMM")
else:print("NA") MM(s_front) and MM(s_end) MM(s_front) MM s_front MM(s_end) MM s_end elif MM(s_front) and not MM(s_end):print("MMYY") MM(s_front) and not MM(s_end) MM(s_front) MM s_front not MM(s_end) MM(s_end) MM s_end elif not MM(s_front) and MM(s_end):print("YYMM") not MM(s_front) and MM(s_end) not MM(s_front) MM(s_front) MM s_front MM(s_end) MM s_end def MM(x):
    if 1<=x<=12:return True
    else:return False def MM(x):
    if 1<=x<=12:return True
    else:return False MM s=input() input() s s_front=int(s[0]+s[1]) int(s[0]+s[1]) s_front s_end=int(s[2]+s[3]) int(s[2]+s[3]) s_end
s=input()
s_front=int(s[0]+s[1])
s_end=int(s[2]+s[3])

def MM(x):
    if 1<=x<=12:return True
    else:return False

if MM(s_front) and MM(s_end):print("AMBIGUOUS")
elif MM(s_front) and not MM(s_end):print("MMYY")
elif not MM(s_front) and MM(s_end):print("YYMM")
else:print("NA")