s = int(input())
l, r = s / 100, s % 100
if 1 <= l <= 12:
    if 1 <= r <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 1 <= r <= 12:
    print('YYMM')
else:
    print('NA') s = int(input()) s int(input()) int input() input l, r = s / 100, s % 100 l s / 100 s 100 r s % 100 s 100 if 1 <= l <= 12:
    if 1 <= r <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 1 <= r <= 12:
    print('YYMM')
else:
    print('NA') 1 <= l <= 12 1 <= l 1 l 12 if 1 <= r <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY') 1 <= r <= 12 1 <= r 1 r 12 print('AMBIGUOUS') print 'AMBIGUOUS' print('MMYY') print 'MMYY' elif 1 <= r <= 12:
    print('YYMM') 1 <= r <= 12 1 <= r 1 r 12 print('YYMM') print 'YYMM' print('NA') print 'NA' r = s / 100, s % 100 s % 100 r l, r = s / 100, s % 100 s / 100 l s = int(input()) int(input()) s
s = int(input())
l, r = s / 100, s % 100
if 1 <= l <= 12:
    if 1 <= r <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 1 <= r <= 12:
    print('YYMM')
else:
    print('NA')
