S = int(input())

if 0 < S//100 < 13:
    if 0 < S%100 < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < S%100 < 13:
        print('YYMM')
    else:
        print('NA') S = int(input()) S int(input()) int input() input if 0 < S//100 < 13:
    if 0 < S%100 < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < S%100 < 13:
        print('YYMM')
    else:
        print('NA') 0 < S//100 < 13 0 < S//100 0 S//100 S 100 13 if 0 < S%100 < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY') 0 < S%100 < 13 0 < S%100 0 S%100 S 100 13 print('AMBIGUOUS') print 'AMBIGUOUS' print('MMYY') print 'MMYY' if 0 < S%100 < 13:
        print('YYMM')
    else:
        print('NA') 0 < S%100 < 13 0 < S%100 0 S%100 S 100 13 print('YYMM') print 'YYMM' print('NA') print 'NA' S = int(input()) int(input()) S
S = int(input())

if 0 < S//100 < 13:
    if 0 < S%100 < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < S%100 < 13:
        print('YYMM')
    else:
        print('NA')