s = int(eval(input()))

a, b = s // 100, s % 100

x = "YY" if a == 0 or a > 12 else "MM"

y = "YY" if b == 0 or b > 12 else "MM"

print((x + y if x != y else "NA" if x == "YY" else "AMBIGUOUS"))

a, b = divmod(int(eval(input())), 100)

x = "MM" if 0 < a < 13 else "YY"

y = "MM" if 0 < b < 13 else "YY"

print((x + y if x != y else "NA" if x == "YY" else "AMBIGUOUS"))

s = int(eval(input()))
a, b = s // 100, s % 100
x = "YY" if a == 0 or a > 12 else "MM"
y = "YY" if b == 0 or b > 12 else "MM"
print((x + y if x != y else "NA" if x == "YY" else "AMBIGUOUS"))

a, b = divmod(int(eval(input())), 100)
x = "MM" if 0 < a < 13 else "YY"
y = "MM" if 0 < b < 13 else "YY"
print((x + y if x != y else "NA" if x == "YY" else "AMBIGUOUS"))

-s = int(eval(input())) -a, b = s // 100, s % 100 -x = "YY" if a == 0 or a > 12 else "MM" -y = "YY" if b == 0 or b > 12 else "MM" +a, b = divmod(int(eval(input())), 100) +x = "MM" if 0 < a < 13 else "YY" +y = "MM" if 0 < b < 13 else "YY"