S=input()
s=list(S)
left=int(s[0])*10+int(s[1])
right=int(s[2])*10+int(s[3])
if 1<=left<=12:
    if 1<=right<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=right<=12:
        print("YYMM")
    else:
        print("NA") S=input() S input() input s=list(S) s list(S) list S left=int(s[0])*10+int(s[1]) left 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 right=int(s[2])*10+int(s[3]) right 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<=left<=12:
    if 1<=right<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=right<=12:
        print("YYMM")
    else:
        print("NA") 1<=left<=12 1<=left 1 left 12 if 1<=right<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY") 1<=right<=12 1<=right 1 right 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 1<=right<=12:
        print("YYMM")
    else:
        print("NA") 1<=right<=12 1<=right 1 right 12 print("YYMM") print "YYMM" print("NA") print "NA" right=int(s[2])*10+int(s[3]) int(s[2])*10+int(s[3]) right s=list(S) list(S) s left=int(s[0])*10+int(s[1]) int(s[0])*10+int(s[1]) left S=input() input() S
S=input()
s=list(S)
left=int(s[0])*10+int(s[1])
right=int(s[2])*10+int(s[3])
if 1<=left<=12:
    if 1<=right<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=right<=12:
        print("YYMM")
    else:
        print("NA")