S = eval(input())



a = S[:2]

b = S[2:]



if 1 <= int(a) <= 12 and 1 <= int(b) <= 12:

    print('AMBIGUOUS')

elif 0 <= int(a) <= 99 and 1 <= int(b) <= 12:

    print('YYMM')

elif 1 <= int(a) <= 12 and 0 <= int(b) <= 99:

    print('MMYY')

else:

    print('NA')
n = eval(input())

a = int(n[:2])

b = int(n[2:])



if 0 < a <= 12 and  (b == 0 or b > 12):

    print('MMYY')

elif (a == 0 or a > 12) and 0 < b <= 12:

    print('YYMM')

elif 0 < a <= 12 and 0 < b <= 12:

    print('AMBIGUOUS')

else:

    print('NA')
S = eval(input())
a = S[:2]
b = S[2:]
if 1 <= int(a) <= 12 and 1 <= int(b) <= 12:
    print("AMBIGUOUS")
elif 0 <= int(a) <= 99 and 1 <= int(b) <= 12:
    print("YYMM")
elif 1 <= int(a) <= 12 and 0 <= int(b) <= 99:
    print("MMYY")
else:
    print("NA")

n = eval(input())
a = int(n[:2])
b = int(n[2:])
if 0 < a <= 12 and (b == 0 or b > 12):
    print("MMYY")
elif (a == 0 or a > 12) and 0 < b <= 12:
    print("YYMM")
elif 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
else:
    print("NA")

-S = eval(input()) -a = S[:2] -b = S[2:] -if 1 <= int(a) <= 12 and 1 <= int(b) <= 12: +n = eval(input()) +a = int(n[:2]) +b = int(n[2:]) +if 0 < a <= 12 and (b == 0 or b > 12): +    print("MMYY") +elif (a == 0 or a > 12) and 0 < b <= 12: +    print("YYMM") +elif 0 < a <= 12 and 0 < b <= 12: -elif 0 <= int(a) <= 99 and 1 <= int(b) <= 12: -    print("YYMM") -elif 1 <= int(a) <= 12 and 0 <= int(b) <= 99: -    print("MMYY")