s = int(input())
a = s//100
b = s%100
if 0 < b and b < 13 and 0 < a and a < 13:
    print("AMBIGUOUS")
elif 0 < b and b < 13:
    print("YYMM")
elif 0 < a and a < 13:
    print("MMYY")
else:
    print("NA") s = int(input()) s int(input()) int input() input a = s//100 a s//100 s 100 b = s%100 b s%100 s 100 if 0 < b and b < 13 and 0 < a and a < 13:
    print("AMBIGUOUS")
elif 0 < b and b < 13:
    print("YYMM")
elif 0 < a and a < 13:
    print("MMYY")
else:
    print("NA") 0 < b and b < 13 and 0 < a and a < 13 0 < b and b < 13 and 0 < a 0 < b and b < 13 0 < b 0 b b < 13 b 13 0 < a 0 a a < 13 a 13 print("AMBIGUOUS") print "AMBIGUOUS" elif 0 < b and b < 13:
    print("YYMM") 0 < b and b < 13 0 < b 0 b b < 13 b 13 print("YYMM") print "YYMM" elif 0 < a and a < 13:
    print("MMYY") 0 < a and a < 13 0 < a 0 a a < 13 a 13 print("MMYY") print "MMYY" print("NA") print "NA" s = int(input()) int(input()) s b = s%100 s%100 b a = s//100 s//100 a
s = int(input())
a = s//100
b = s%100
if 0 < b and b < 13 and 0 < a and a < 13:
    print("AMBIGUOUS")
elif 0 < b and b < 13:
    print("YYMM")
elif 0 < a and a < 13:
    print("MMYY")
else:
    print("NA")