import math

import itertools

import statistics

#n = int(input())

s=eval(input())

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

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

# yymm yy>12 and 12>=mm>=1

# mmyy 1<=mm<=12 and yy > 12

# doble 1<=yy<=12 and  1<=mm<=12

# na mm=0 and yy?12

if 0<a<13 and 0<b<13:

    print("AMBIGUOUS")

elif a > 12 and 0<b<13:

    print("YYMM")

elif 0<a<13 and b > 13:

    print("MMYY")

else:

    if 0<a<13 and b==0:

        print("MMYY")

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

        print("YYMM")

    else:   

        print("NA")

s = eval(input())

start = int(s[0]+s[1])

end = int(s[2]+s[3])



if 1 <= start <= 12 and 1 <= end <= 12:

    print("AMBIGUOUS")

elif 1 <= start <= 12 and (end > 12 or end == 0):

    print("MMYY")

elif (start > 12 or start == 0) and 1 <= end <= 12:

    print("YYMM")

else:

    print("NA")

import math
import itertools
import statistics

# n = int(input())
s = eval(input())
a = int(s[0]) * 10 + int(s[1])
b = int(s[2]) * 10 + int(s[3])
# yymm yy>12 and 12>=mm>=1
# mmyy 1<=mm<=12 and yy > 12
# doble 1<=yy<=12 and  1<=mm<=12
# na mm=0 and yy?12
if 0 < a < 13 and 0 < b < 13:
    print("AMBIGUOUS")
elif a > 12 and 0 < b < 13:
    print("YYMM")
elif 0 < a < 13 and b > 13:
    print("MMYY")
else:
    if 0 < a < 13 and b == 0:
        print("MMYY")
    elif a == 0 and 0 < b < 13:
        print("YYMM")
    else:
        print("NA")

s = eval(input())
start = int(s[0] + s[1])
end = int(s[2] + s[3])
if 1 <= start <= 12 and 1 <= end <= 12:
    print("AMBIGUOUS")
elif 1 <= start <= 12 and (end > 12 or end == 0):
    print("MMYY")
elif (start > 12 or start == 0) and 1 <= end <= 12:
    print("YYMM")
else:
    print("NA")

-import math -import itertools -import statistics - -# n = int(input()) -a = int(s[0]) * 10 + int(s[1]) -b = int(s[2]) * 10 + int(s[3]) -# yymm yy>12 and 12>=mm>=1 -# mmyy 1<=mm<=12 and yy > 12 -# doble 1<=yy<=12 and  1<=mm<=12 -# na mm=0 and yy?12 -if 0 < a < 13 and 0 < b < 13: +start = int(s[0] + s[1]) +end = int(s[2] + s[3]) +if 1 <= start <= 12 and 1 <= end <= 12: -elif a > 12 and 0 < b < 13: +elif 1 <= start <= 12 and (end > 12 or end == 0): +    print("MMYY") +elif (start > 12 or start == 0) and 1 <= end <= 12: -elif 0 < a < 13 and b > 13: -    print("MMYY") -    if 0 < a < 13 and b == 0: -        print("MMYY") -    elif a == 0 and 0 < b < 13: -        print("YYMM") -    else: -        print("NA") +    print("NA")