import re

s = list(eval(input()))

match_MMYY = re.match(r'0[1-9]|1[0-2]', "".join(s[:2]))

match_YYMM = re.match(r'0[1-9]|1[0-2]', "".join(s[2:]))

if (match_YYMM and match_MMYY):

    answer = 'AMBIGUOUS'

elif(match_YYMM):

    answer = 'YYMM'

elif(match_MMYY):

    answer = 'MMYY'

else:

    answer = 'NA'



print(answer)
s = list(eval(input()))

MMYY = False

YYMM = False

for x in range(1,13):

    MMYY = MMYY or (x == int(''.join(s[:2])))

    YYMM = YYMM or (x == int(''.join(s[2:])))

if MMYY and YYMM:

    ans = 'AMBIGUOUS'

elif(YYMM):

    ans = 'YYMM'

elif(MMYY):

    ans = 'MMYY'

else:

    ans = 'NA'



print(ans)
import re

s = list(eval(input()))
match_MMYY = re.match(r"0[1-9]|1[0-2]", "".join(s[:2]))
match_YYMM = re.match(r"0[1-9]|1[0-2]", "".join(s[2:]))
if match_YYMM and match_MMYY:
    answer = "AMBIGUOUS"
elif match_YYMM:
    answer = "YYMM"
elif match_MMYY:
    answer = "MMYY"
else:
    answer = "NA"
print(answer)

s = list(eval(input()))
MMYY = False
YYMM = False
for x in range(1, 13):
    MMYY = MMYY or (x == int("".join(s[:2])))
    YYMM = YYMM or (x == int("".join(s[2:])))
if MMYY and YYMM:
    ans = "AMBIGUOUS"
elif YYMM:
    ans = "YYMM"
elif MMYY:
    ans = "MMYY"
else:
    ans = "NA"
print(ans)

-import re - -match_MMYY = re.match(r"0[1-9]|1[0-2]", "".join(s[:2])) -match_YYMM = re.match(r"0[1-9]|1[0-2]", "".join(s[2:])) -if match_YYMM and match_MMYY: -    answer = "AMBIGUOUS" -elif match_YYMM: -    answer = "YYMM" -elif match_MMYY: -    answer = "MMYY" +MMYY = False +YYMM = False +for x in range(1, 13): +    MMYY = MMYY or (x == int("".join(s[:2]))) +    YYMM = YYMM or (x == int("".join(s[2:]))) +if MMYY and YYMM: +    ans = "AMBIGUOUS" +elif YYMM: +    ans = "YYMM" +elif MMYY: +    ans = "MMYY" -    answer = "NA" -print(answer) +    ans = "NA" +print(ans)