#B

s = list(eval(input()))

left = int(s[0])*10+int(s[1])

right = int(s[2])*10+int(s[3])

if 0 < left <= 12:

    if 0 < right <= 12:

        print("AMBIGUOUS")

    else:

        print('MMYY')

elif 0 < right <= 12:

    print('YYMM')

else:

    print('NA')

#B

s = eval(input())

# print(int(s[0:2]), int(s[2:4]))

if 1 <= int(s[0:2]) <= 12 and 1 <= int(s[2:4]) <= 12:

    print('AMBIGUOUS')

elif 1 <= int(s[0:2]) <= 12:

    print('MMYY')

elif 1 <= int(s[2:4]) <= 12:

    print('YYMM')

else:

    print('NA')

# B
s = list(eval(input()))
left = int(s[0]) * 10 + int(s[1])
right = int(s[2]) * 10 + int(s[3])
if 0 < left <= 12:
    if 0 < right <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 0 < right <= 12:
    print("YYMM")
else:
    print("NA")

# B
s = eval(input())
# print(int(s[0:2]), int(s[2:4]))
if 1 <= int(s[0:2]) <= 12 and 1 <= int(s[2:4]) <= 12:
    print("AMBIGUOUS")
elif 1 <= int(s[0:2]) <= 12:
    print("MMYY")
elif 1 <= int(s[2:4]) <= 12:
    print("YYMM")
else:
    print("NA")

-s = list(eval(input())) -left = int(s[0]) * 10 + int(s[1]) -right = int(s[2]) * 10 + int(s[3]) -if 0 < left <= 12: -    if 0 < right <= 12: -        print("AMBIGUOUS") -    else: -        print("MMYY") -elif 0 < right <= 12: +s = eval(input()) +# print(int(s[0:2]), int(s[2:4])) +if 1 <= int(s[0:2]) <= 12 and 1 <= int(s[2:4]) <= 12: +    print("AMBIGUOUS") +elif 1 <= int(s[0:2]) <= 12: +    print("MMYY") +elif 1 <= int(s[2:4]) <= 12: