s = list(input())

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

if 0<a<13 and 0<b<13:
    print("AMBIGUOUS")
elif 0<a<13:
    print("MMYY")
elif 0<b<13:
    print("YYMM")
else:
    print("NA") s = list(input()) s list(input()) list input() input a = 10*int(s[0])+int(s[1]) a 10*int(s[0])+int(s[1]) 10*int(s[0]) 10 int(s[0]) int s[0] s 0 int(s[1]) int s[1] s 1 b = 10*int(s[2])+int(s[3]) b 10*int(s[2])+int(s[3]) 10*int(s[2]) 10 int(s[2]) int s[2] s 2 int(s[3]) int s[3] s 3 if 0<a<13 and 0<b<13:
    print("AMBIGUOUS")
elif 0<a<13:
    print("MMYY")
elif 0<b<13:
    print("YYMM")
else:
    print("NA") 0<a<13 and 0<b<13 0<a<13 0<a 0 a 13 0<b<13 0<b 0 b 13 print("AMBIGUOUS") print "AMBIGUOUS" elif 0<a<13:
    print("MMYY") 0<a<13 0<a 0 a 13 print("MMYY") print "MMYY" elif 0<b<13:
    print("YYMM") 0<b<13 0<b 0 b 13 print("YYMM") print "YYMM" print("NA") print "NA" s = list(input()) list(input()) s b = 10*int(s[2])+int(s[3]) 10*int(s[2])+int(s[3]) b a = 10*int(s[0])+int(s[1]) 10*int(s[0])+int(s[1]) a
s = list(input())

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

if 0<a<13 and 0<b<13:
    print("AMBIGUOUS")
elif 0<a<13:
    print("MMYY")
elif 0<b<13:
    print("YYMM")
else:
    print("NA")