a=int(input())
l=a/100
r=a%100
if 1<=l and l<=12:
    if 1<=r and  r<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=r and r<=12:
        print("YYMM")
    else:
        print("NA") a=int(input()) a int(input()) int input() input l=a/100 l a/100 a 100 r=a%100 r a%100 a 100 if 1<=l and l<=12:
    if 1<=r and  r<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=r and r<=12:
        print("YYMM")
    else:
        print("NA") 1<=l and l<=12 1<=l 1 l l<=12 l 12 if 1<=r and  r<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY") 1<=r and  r<=12 1<=r 1 r r<=12 r 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 1<=r and r<=12:
        print("YYMM")
    else:
        print("NA") 1<=r and r<=12 1<=r 1 r r<=12 r 12 print("YYMM") print "YYMM" print("NA") print "NA" l=a/100 a/100 l a=int(input()) int(input()) a r=a%100 a%100 r
a=int(input())
l=a/100
r=a%100
if 1<=l and l<=12:
    if 1<=r and  r<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=r and r<=12:
        print("YYMM")
    else:
        print("NA")