s = input()
sb = s[:2]
sa = s[2:]
if 1<=int(sb)<=12 and (13 <= int(sa) or int(sa)==0):
    print('MMYY')
elif 1<=int(sa)<=12 and (13 <= int(sb) or int(sb)==0):
    print('YYMM')
elif 1<=int(sb)<=12 and 1<=int(sb)<=12:
    print('AMBIGUOUS')
else:
    print('NA') s = input() s input() input sb = s[:2] sb s[:2] s :2 2 sa = s[2:] sa s[2:] s 2: 2 if 1<=int(sb)<=12 and (13 <= int(sa) or int(sa)==0):
    print('MMYY')
elif 1<=int(sa)<=12 and (13 <= int(sb) or int(sb)==0):
    print('YYMM')
elif 1<=int(sb)<=12 and 1<=int(sb)<=12:
    print('AMBIGUOUS')
else:
    print('NA') 1<=int(sb)<=12 and (13 <= int(sa) or int(sa)==0) 1<=int(sb)<=12 1<=int(sb) 1 int(sb) int sb 12 13 <= int(sa) or int(sa)==0 13 <= int(sa) 13 int(sa) int sa int(sa)==0 int(sa) int sa 0 print('MMYY') print 'MMYY' elif 1<=int(sa)<=12 and (13 <= int(sb) or int(sb)==0):
    print('YYMM') 1<=int(sa)<=12 and (13 <= int(sb) or int(sb)==0) 1<=int(sa)<=12 1<=int(sa) 1 int(sa) int sa 12 13 <= int(sb) or int(sb)==0 13 <= int(sb) 13 int(sb) int sb int(sb)==0 int(sb) int sb 0 print('YYMM') print 'YYMM' elif 1<=int(sb)<=12 and 1<=int(sb)<=12:
    print('AMBIGUOUS') 1<=int(sb)<=12 and 1<=int(sb)<=12 1<=int(sb)<=12 1<=int(sb) 1 int(sb) int sb 12 1<=int(sb)<=12 1<=int(sb) 1 int(sb) int sb 12 print('AMBIGUOUS') print 'AMBIGUOUS' print('NA') print 'NA' s = input() input() s sa = s[2:] s[2:] sa sb = s[:2] s[:2] sb
s = input()
sb = s[:2]
sa = s[2:]
if 1<=int(sb)<=12 and (13 <= int(sa) or int(sa)==0):
    print('MMYY')
elif 1<=int(sa)<=12 and (13 <= int(sb) or int(sb)==0):
    print('YYMM')
elif 1<=int(sb)<=12 and 1<=int(sb)<=12:
    print('AMBIGUOUS')
else:
    print('NA')
