s = input()
bef = s[:2]
aft = s[2:]

if 1 <= int(bef) <= 12:
    if 1 <= int(aft) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(aft) <= 12:
        print("YYMM")
    else:
        print("NA") s = input() s input() input bef = s[:2] bef s[:2] s :2 2 aft = s[2:] aft s[2:] s 2: 2 if 1 <= int(bef) <= 12:
    if 1 <= int(aft) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(aft) <= 12:
        print("YYMM")
    else:
        print("NA") 1 <= int(bef) <= 12 1 <= int(bef) 1 int(bef) int bef 12 if 1 <= int(aft) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY") 1 <= int(aft) <= 12 1 <= int(aft) 1 int(aft) int aft 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 1 <= int(aft) <= 12:
        print("YYMM")
    else:
        print("NA") 1 <= int(aft) <= 12 1 <= int(aft) 1 int(aft) int aft 12 print("YYMM") print "YYMM" print("NA") print "NA" s = input() input() s aft = s[2:] s[2:] aft bef = s[:2] s[:2] bef
s = input()
bef = s[:2]
aft = s[2:]

if 1 <= int(bef) <= 12:
    if 1 <= int(aft) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(aft) <= 12:
        print("YYMM")
    else:
        print("NA")