S=input()
x=int(S[:2])
y=int(S[2:4])
if 1<=x<=12:
    if 1<=y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=y<=12:
        print("YYMM")
    else:
        print("NA") S=input() S input() input x=int(S[:2]) x int(S[:2]) int S[:2] S :2 2 y=int(S[2:4]) y int(S[2:4]) int S[2:4] S 2:4 2 4 if 1<=x<=12:
    if 1<=y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=y<=12:
        print("YYMM")
    else:
        print("NA") 1<=x<=12 1<=x 1 x 12 if 1<=y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY") 1<=y<=12 1<=y 1 y 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 1<=y<=12:
        print("YYMM")
    else:
        print("NA") 1<=y<=12 1<=y 1 y 12 print("YYMM") print "YYMM" print("NA") print "NA" S=input() input() S x=int(S[:2]) int(S[:2]) x y=int(S[2:4]) int(S[2:4]) y
S=input()
x=int(S[:2])
y=int(S[2:4])
if 1<=x<=12:
    if 1<=y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=y<=12:
        print("YYMM")
    else:
        print("NA")