S = str(input())
year = int(S[0] + S[1])
month = int(S[2] + S[3])
if year <= 12 and year >= 1 and month >= 1 and month <= 12:
    print('AMBIGUOUS')
elif year >= 0 and year <= 99 and month >= 1 and month <= 12:
    print('YYMM')
elif year >= 1 and year <= 12 and month >= 0 and month <= 99:
    print('MMYY')
else:
    print('NA') S = str(input()) S str(input()) str input() input year = int(S[0] + S[1]) year int(S[0] + S[1]) int S[0] + S[1] S[0] S 0 S[1] S 1 month = int(S[2] + S[3]) month int(S[2] + S[3]) int S[2] + S[3] S[2] S 2 S[3] S 3 if year <= 12 and year >= 1 and month >= 1 and month <= 12:
    print('AMBIGUOUS')
elif year >= 0 and year <= 99 and month >= 1 and month <= 12:
    print('YYMM')
elif year >= 1 and year <= 12 and month >= 0 and month <= 99:
    print('MMYY')
else:
    print('NA') year <= 12 and year >= 1 and month >= 1 and month <= 12 year <= 12 and year >= 1 and month >= 1 year <= 12 and year >= 1 year <= 12 year 12 year >= 1 year 1 month >= 1 month 1 month <= 12 month 12 print('AMBIGUOUS') print 'AMBIGUOUS' elif year >= 0 and year <= 99 and month >= 1 and month <= 12:
    print('YYMM') year >= 0 and year <= 99 and month >= 1 and month <= 12 year >= 0 and year <= 99 and month >= 1 year >= 0 and year <= 99 year >= 0 year 0 year <= 99 year 99 month >= 1 month 1 month <= 12 month 12 print('YYMM') print 'YYMM' elif year >= 1 and year <= 12 and month >= 0 and month <= 99:
    print('MMYY') year >= 1 and year <= 12 and month >= 0 and month <= 99 year >= 1 and year <= 12 and month >= 0 year >= 1 and year <= 12 year >= 1 year 1 year <= 12 year 12 month >= 0 month 0 month <= 99 month 99 print('MMYY') print 'MMYY' print('NA') print 'NA' S = str(input()) str(input()) S year = int(S[0] + S[1]) int(S[0] + S[1]) year month = int(S[2] + S[3]) int(S[2] + S[3]) month
S = str(input())
year = int(S[0] + S[1])
month = int(S[2] + S[3])
if year <= 12 and year >= 1 and month >= 1 and month <= 12:
    print('AMBIGUOUS')
elif year >= 0 and year <= 99 and month >= 1 and month <= 12:
    print('YYMM')
elif year >= 1 and year <= 12 and month >= 0 and month <= 99:
    print('MMYY')
else:
    print('NA')