s = input()
first = int(s[:2])
second = int(s[2:])

month = [False,False]


if(1 <= first and first <= 12):
    month[0] = True

if(1 <= second and second <= 12):
    month[1] = True
    
if(month[0] & month[1]):
    print('AMBIGUOUS')
elif(month[0]):
    print('MMYY')
elif(month[1]):
    print('YYMM')
else:
    print('NA')
 s = input() s input() input first = int(s[:2]) first int(s[:2]) int s[:2] s :2 2 second = int(s[2:]) second int(s[2:]) int s[2:] s 2: 2 month = [False,False] month [False,False] False False if(1 <= first and first <= 12):
    month[0] = True 1 <= first and first <= 12 1 <= first 1 first first <= 12 first 12 month[0] = True month[0] month 0 True if(1 <= second and second <= 12):
    month[1] = True
     1 <= second and second <= 12 1 <= second 1 second second <= 12 second 12 month[1] = True month[1] month 1 True if(month[0] & month[1]):
    print('AMBIGUOUS')
elif(month[0]):
    print('MMYY')
elif(month[1]):
    print('YYMM')
else:
    print('NA') month[0] & month[1] month[0] month 0 month[1] month 1 print('AMBIGUOUS') print 'AMBIGUOUS' elif(month[0]):
    print('MMYY') month[0] month 0 print('MMYY') print 'MMYY' elif(month[1]):
    print('YYMM') month[1] month 1 print('YYMM') print 'YYMM' print('NA') print 'NA' first = int(s[:2]) int(s[:2]) first s = input() input() s month = [False,False] [False,False] month second = int(s[2:]) int(s[2:]) second
s = input()
first = int(s[:2])
second = int(s[2:])

month = [False,False]


if(1 <= first and first <= 12):
    month[0] = True

if(1 <= second and second <= 12):
    month[1] = True
    
if(month[0] & month[1]):
    print('AMBIGUOUS')
elif(month[0]):
    print('MMYY')
elif(month[1]):
    print('YYMM')
else:
    print('NA')

