s = input()
a, b = s[:2], s[2:]
if '01' <= a <= '12':
    if '01' <= b <= '12':
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if '01' <= b <= '12':
        print('YYMM')
    else:
        print('NA') s = input() s input() input a, b = s[:2], s[2:] a s[:2] s :2 2 b s[2:] s 2: 2 if '01' <= a <= '12':
    if '01' <= b <= '12':
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if '01' <= b <= '12':
        print('YYMM')
    else:
        print('NA') '01' <= a <= '12' '01' <= a '01' a '12' if '01' <= b <= '12':
        print('AMBIGUOUS')
    else:
        print('MMYY') '01' <= b <= '12' '01' <= b '01' b '12' print('AMBIGUOUS') print 'AMBIGUOUS' print('MMYY') print 'MMYY' if '01' <= b <= '12':
        print('YYMM')
    else:
        print('NA') '01' <= b <= '12' '01' <= b '01' b '12' print('YYMM') print 'YYMM' print('NA') print 'NA' b = s[:2], s[2:] s[2:] b s = input() input() s a, b = s[:2], s[2:] s[:2] a
s = input()
a, b = s[:2], s[2:]
if '01' <= a <= '12':
    if '01' <= b <= '12':
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if '01' <= b <= '12':
        print('YYMM')
    else:
        print('NA')
