s = input()

aa = int(s[0])*10 + int(s[1])
bb = int(s[2])*10 + int(s[3])

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

aa = int(s[0])*10 + int(s[1])
bb = int(s[2])*10 + int(s[3])

if 1 <= aa <= 12 and 1 <= bb <= 12 :
    print("AMBIGUOUS")
elif 1 <= aa <= 12 and bb == 0 :
    print("MMYY")
elif 1 <= aa <= 12 and 13 <= bb :
    print("MMYY")
elif aa == 0 and 1<= bb <= 12 :
    print("YYMM")
elif 13<=aa and 1<=bb<=12 :
    print("YYMM")
else :
    print("NA")
