S=input()
x=int(S[:2])
y=int(S[2:])
if x==0:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA")
elif 0<x<=12:
    if 0<y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif x>=13:
    if 0<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:]) y int(S[2:]) int S[2:] S 2: 2 if x==0:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA")
elif 0<x<=12:
    if 0<y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif x>=13:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA") x==0 x 0 if 0<y<=12:
        print("YYMM")
    else:
        print("NA") 0<y<=12 0<y 0 y 12 print("YYMM") print "YYMM" print("NA") print "NA" elif 0<x<=12:
    if 0<y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY") 0<x<=12 0<x 0 x 12 if 0<y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY") 0<y<=12 0<y 0 y 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" elif x>=13:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA") x>=13 x 13 if 0<y<=12:
        print("YYMM")
    else:
        print("NA") 0<y<=12 0<y 0 y 12 print("YYMM") print "YYMM" print("NA") print "NA" y=int(S[2:]) int(S[2:]) y x=int(S[:2]) int(S[:2]) x S=input() input() S
S=input()
x=int(S[:2])
y=int(S[2:])
if x==0:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA")
elif 0<x<=12:
    if 0<y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif x>=13:
    if 0<y<=12:
        print("YYMM")
    else:
        print("NA")