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