S = str(input())
front = int(S[:2])
back = int(S[2:])

if front > 12 or front == 0:
    if 0 < back <= 12 :
        print("YYMM")
    else:
        print("NA")
elif front <= 12 or front == 0:
    if 0 < back <= 12: 
        print("AMBIGUOUS")
    else:
        print("MMYY") S = str(input()) S str(input()) str input() input front = int(S[:2]) front int(S[:2]) int S[:2] S :2 2 back = int(S[2:]) back int(S[2:]) int S[2:] S 2: 2 if front > 12 or front == 0:
    if 0 < back <= 12 :
        print("YYMM")
    else:
        print("NA")
elif front <= 12 or front == 0:
    if 0 < back <= 12: 
        print("AMBIGUOUS")
    else:
        print("MMYY") front > 12 or front == 0 front > 12 front 12 front == 0 front 0 if 0 < back <= 12 :
        print("YYMM")
    else:
        print("NA") 0 < back <= 12 0 < back 0 back 12 print("YYMM") print "YYMM" print("NA") print "NA" elif front <= 12 or front == 0:
    if 0 < back <= 12: 
        print("AMBIGUOUS")
    else:
        print("MMYY") front <= 12 or front == 0 front <= 12 front 12 front == 0 front 0 if 0 < back <= 12: 
        print("AMBIGUOUS")
    else:
        print("MMYY") 0 < back <= 12 0 < back 0 back 12 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" back = int(S[2:]) int(S[2:]) back front = int(S[:2]) int(S[:2]) front S = str(input()) str(input()) S
S = str(input())
front = int(S[:2])
back = int(S[2:])

if front > 12 or front == 0:
    if 0 < back <= 12 :
        print("YYMM")
    else:
        print("NA")
elif front <= 12 or front == 0:
    if 0 < back <= 12: 
        print("AMBIGUOUS")
    else:
        print("MMYY")