s = input()
first = 0 < int(s[:2]) < 13
second = 0 < int(s[2:]) < 13

if first and second:
    print('AMBIGUOUS')
elif first:
    print('MMYY')
elif second:
    print('YYMM')
else:
    print('NA') s = input() s input() input first = 0 < int(s[:2]) < 13 first 0 < int(s[:2]) < 13 0 < int(s[:2]) 0 int(s[:2]) int s[:2] s :2 2 13 second = 0 < int(s[2:]) < 13 second 0 < int(s[2:]) < 13 0 < int(s[2:]) 0 int(s[2:]) int s[2:] s 2: 2 13 if first and second:
    print('AMBIGUOUS')
elif first:
    print('MMYY')
elif second:
    print('YYMM')
else:
    print('NA') first and second first second print('AMBIGUOUS') print 'AMBIGUOUS' elif first:
    print('MMYY') first print('MMYY') print 'MMYY' elif second:
    print('YYMM') second print('YYMM') print 'YYMM' print('NA') print 'NA' second = 0 < int(s[2:]) < 13 0 < int(s[2:]) < 13 second s = input() input() s first = 0 < int(s[:2]) < 13 0 < int(s[:2]) < 13 first
s = input()
first = 0 < int(s[:2]) < 13
second = 0 < int(s[2:]) < 13

if first and second:
    print('AMBIGUOUS')
elif first:
    print('MMYY')
elif second:
    print('YYMM')
else:
    print('NA')
