# 126 B

s = input()

fir = int(s[:2])
sec = int(s[2:])

if fir > 0 or sec > 0:
    if 1 <= fir <= 12 and 1 <= sec <= 12 :
        print("AMBIGUOUS")
    elif 1 <= fir <= 12: 
        print("MMYY")
    elif 1 <= sec <= 12:
        print("YYMM") 
    else:
        print("NA")
else:
    print("NA") s = input() s input() input fir = int(s[:2]) fir int(s[:2]) int s[:2] s :2 2 sec = int(s[2:]) sec int(s[2:]) int s[2:] s 2: 2 if fir > 0 or sec > 0:
    if 1 <= fir <= 12 and 1 <= sec <= 12 :
        print("AMBIGUOUS")
    elif 1 <= fir <= 12: 
        print("MMYY")
    elif 1 <= sec <= 12:
        print("YYMM") 
    else:
        print("NA")
else:
    print("NA") fir > 0 or sec > 0 fir > 0 fir 0 sec > 0 sec 0 if 1 <= fir <= 12 and 1 <= sec <= 12 :
        print("AMBIGUOUS")
    elif 1 <= fir <= 12: 
        print("MMYY")
    elif 1 <= sec <= 12:
        print("YYMM") 
    else:
        print("NA") 1 <= fir <= 12 and 1 <= sec <= 12 1 <= fir <= 12 1 <= fir 1 fir 12 1 <= sec <= 12 1 <= sec 1 sec 12 print("AMBIGUOUS") print "AMBIGUOUS" elif 1 <= fir <= 12: 
        print("MMYY")
     1 <= fir <= 12 1 <= fir 1 fir 12 print("MMYY") print "MMYY" elif 1 <= sec <= 12:
        print("YYMM") 
     1 <= sec <= 12 1 <= sec 1 sec 12 print("YYMM") print "YYMM" print("NA") print "NA" print("NA") print "NA" sec = int(s[2:]) int(s[2:]) sec fir = int(s[:2]) int(s[:2]) fir s = input() input() s
# 126 B

s = input()

fir = int(s[:2])
sec = int(s[2:])

if fir > 0 or sec > 0:
    if 1 <= fir <= 12 and 1 <= sec <= 12 :
        print("AMBIGUOUS")
    elif 1 <= fir <= 12: 
        print("MMYY")
    elif 1 <= sec <= 12:
        print("YYMM") 
    else:
        print("NA")
else:
    print("NA")
