# -*- coding: utf-8 -*-

s = input()

head = s[:2]
tail = s[2:]

result = ['MMYY', 'YYMM', 'AMBIGUOUS', 'NA']
judge = [0, 0]
months = [f'{m:02}' for m in range(1, 13)]
if head in months:
    judge[0] += 1
if tail in months:

    judge[1] += 1


if sum(judge) == 2:
    print(result[2])

elif sum(judge) == 0:
    print(result[3])
else:
    print(result[judge.index(1)]) s = input() s input() input head = s[:2] head s[:2] s :2 2 tail = s[2:] tail s[2:] s 2: 2 result = ['MMYY', 'YYMM', 'AMBIGUOUS', 'NA'] result ['MMYY', 'YYMM', 'AMBIGUOUS', 'NA'] 'MMYY' 'YYMM' 'AMBIGUOUS' 'NA' judge = [0, 0] judge [0, 0] 0 0 f'{m:02}' for m in range(1, 13) for m in range(1, 13) m range(1, 13) range 1 13 for m in range(1, 13) f'{m:02}' months = [f'{m:02}' for m in range(1, 13)] months [f'{m:02}' for m in range(1, 13)] if head in months:
    judge[0] += 1 head in months head months judge[0] += 1 judge[0] judge 0 1 if tail in months:

    judge[1] += 1 tail in months tail months judge[1] += 1 judge[1] judge 1 1 if sum(judge) == 2:
    print(result[2])

elif sum(judge) == 0:
    print(result[3])
else:
    print(result[judge.index(1)]) sum(judge) == 2 sum(judge) sum judge 2 print(result[2]) print result[2] result 2 elif sum(judge) == 0:
    print(result[3]) sum(judge) == 0 sum(judge) sum judge 0 print(result[3]) print result[3] result 3 print(result[judge.index(1)]) print result[judge.index(1)] result judge.index(1) judge.index judge index 1 s = input() input() s result = ['MMYY', 'YYMM', 'AMBIGUOUS', 'NA'] ['MMYY', 'YYMM', 'AMBIGUOUS', 'NA'] result tail = s[2:] s[2:] tail judge = [0, 0] [0, 0] judge months = [f'{m:02}' for m in range(1, 13)] [f'{m:02}' for m in range(1, 13)] months head = s[:2] s[:2] head
# -*- coding: utf-8 -*-

s = input()

head = s[:2]
tail = s[2:]

result = ['MMYY', 'YYMM', 'AMBIGUOUS', 'NA']
judge = [0, 0]
months = [f'{m:02}' for m in range(1, 13)]
if head in months:
    judge[0] += 1
if tail in months:

    judge[1] += 1


if sum(judge) == 2:
    print(result[2])

elif sum(judge) == 0:
    print(result[3])
else:
    print(result[judge.index(1)])
