S = input()
left = int(S[:2])
right = int(S[2:])
year_flag = [0, 0]

if left > 12 or left == 0:
    year_flag[0] += 1
if right > 12 or right == 0:
    year_flag[1] += 1

if sum(year_flag) == 2:
    print('NA')
elif sum(year_flag) == 0:
    print('AMBIGUOUS')
elif year_flag[0] == 1:
    print('YYMM')
else:
    print('MMYY') S = input() S input() input left = int(S[:2]) left int(S[:2]) int S[:2] S :2 2 right = int(S[2:]) right int(S[2:]) int S[2:] S 2: 2 year_flag = [0, 0] year_flag [0, 0] 0 0 if left > 12 or left == 0:
    year_flag[0] += 1 left > 12 or left == 0 left > 12 left 12 left == 0 left 0 year_flag[0] += 1 year_flag[0] year_flag 0 1 if right > 12 or right == 0:
    year_flag[1] += 1 right > 12 or right == 0 right > 12 right 12 right == 0 right 0 year_flag[1] += 1 year_flag[1] year_flag 1 1 if sum(year_flag) == 2:
    print('NA')
elif sum(year_flag) == 0:
    print('AMBIGUOUS')
elif year_flag[0] == 1:
    print('YYMM')
else:
    print('MMYY') sum(year_flag) == 2 sum(year_flag) sum year_flag 2 print('NA') print 'NA' elif sum(year_flag) == 0:
    print('AMBIGUOUS') sum(year_flag) == 0 sum(year_flag) sum year_flag 0 print('AMBIGUOUS') print 'AMBIGUOUS' elif year_flag[0] == 1:
    print('YYMM') year_flag[0] == 1 year_flag[0] year_flag 0 1 print('YYMM') print 'YYMM' print('MMYY') print 'MMYY' left = int(S[:2]) int(S[:2]) left S = input() input() S right = int(S[2:]) int(S[2:]) right year_flag = [0, 0] [0, 0] year_flag
S = input()
left = int(S[:2])
right = int(S[2:])
year_flag = [0, 0]

if left > 12 or left == 0:
    year_flag[0] += 1
if right > 12 or right == 0:
    year_flag[1] += 1

if sum(year_flag) == 2:
    print('NA')
elif sum(year_flag) == 0:
    print('AMBIGUOUS')
elif year_flag[0] == 1:
    print('YYMM')
else:
    print('MMYY')
