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

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

if 1 <= a and a <= 12 and 1<= b and b <=12:
    print("AMBIGUOUS")
elif 1 <= a <=12 and (12 < b or b < 1):
    print("MMYY")
elif (12 < a or a < 1) and 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")