S = eval(input())

S1 = int(S[:2])

S2 = int(S[2:])

b1,b2 = False,False

if 1 <= S1 <= 12:

    b1 = True

if 1 <= S2 <= 12:

    b2 = True

print(('AMBIGUOUS' if b1 and b2 else 'YYMM' if b2 else 'MMYY' if b1 else 'NA'))
# coding: utf-8

import sys



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



S = list(sr())

head = int(''.join(S[:2]))

tail = int(''.join(S[2:]))

bl_head = (1 <= head <= 12)

bl_tail = (1 <= tail <= 12)

if bl_head and bl_tail:

    answer = "AMBIGUOUS"

elif bl_head:

    answer = "MMYY"

elif bl_tail:

    answer = "YYMM"

else:

    answer = "NA"



print(answer)

S = eval(input())
S1 = int(S[:2])
S2 = int(S[2:])
b1, b2 = False, False
if 1 <= S1 <= 12:
    b1 = True
if 1 <= S2 <= 12:
    b2 = True
print(("AMBIGUOUS" if b1 and b2 else "YYMM" if b2 else "MMYY" if b1 else "NA"))

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
S = list(sr())
head = int("".join(S[:2]))
tail = int("".join(S[2:]))
bl_head = 1 <= head <= 12
bl_tail = 1 <= tail <= 12
if bl_head and bl_tail:
    answer = "AMBIGUOUS"
elif bl_head:
    answer = "MMYY"
elif bl_tail:
    answer = "YYMM"
else:
    answer = "NA"
print(answer)

-S = eval(input()) -S1 = int(S[:2]) -S2 = int(S[2:]) -b1, b2 = False, False -if 1 <= S1 <= 12: -    b1 = True -if 1 <= S2 <= 12: -    b2 = True -print(("AMBIGUOUS" if b1 and b2 else "YYMM" if b2 else "MMYY" if b1 else "NA")) +# coding: utf-8 +import sys + +sr = lambda: sys.stdin.readline().rstrip() +ir = lambda: int(sr()) +lr = lambda: list(map(int, sr().split())) +S = list(sr()) +head = int("".join(S[:2])) +tail = int("".join(S[2:])) +bl_head = 1 <= head <= 12 +bl_tail = 1 <= tail <= 12 +if bl_head and bl_tail: +    answer = "AMBIGUOUS" +elif bl_head: +    answer = "MMYY" +elif bl_tail: +    answer = "YYMM" +else: +    answer = "NA" +print(answer)