S = input()

F = int(S[:2])
B = int(S[2:])

if F == 0 and B == 0:
    print('NA')
elif (F == 0 and B > 12) or (B == 0 and F > 12):
    print('NA')
elif F == 0:
    print('YYMM')
elif B == 0:
    print('MMYY')
elif (F <= 12 and B <= 12):
    print('AMBIGUOUS')
elif F > 12 and B <= 12:
    print('YYMM')
elif F <= 12 and B > 12:
    print('MMYY')
else:
    print('NA') S = input() S input() input F = int(S[:2]) F int(S[:2]) int S[:2] S :2 2 B = int(S[2:]) B int(S[2:]) int S[2:] S 2: 2 if F == 0 and B == 0:
    print('NA')
elif (F == 0 and B > 12) or (B == 0 and F > 12):
    print('NA')
elif F == 0:
    print('YYMM')
elif B == 0:
    print('MMYY')
elif (F <= 12 and B <= 12):
    print('AMBIGUOUS')
elif F > 12 and B <= 12:
    print('YYMM')
elif F <= 12 and B > 12:
    print('MMYY')
else:
    print('NA') F == 0 and B == 0 F == 0 F 0 B == 0 B 0 print('NA') print 'NA' elif (F == 0 and B > 12) or (B == 0 and F > 12):
    print('NA') (F == 0 and B > 12) or (B == 0 and F > 12) F == 0 and B > 12 F == 0 F 0 B > 12 B 12 B == 0 and F > 12 B == 0 B 0 F > 12 F 12 print('NA') print 'NA' elif F == 0:
    print('YYMM') F == 0 F 0 print('YYMM') print 'YYMM' elif B == 0:
    print('MMYY') B == 0 B 0 print('MMYY') print 'MMYY' elif (F <= 12 and B <= 12):
    print('AMBIGUOUS') F <= 12 and B <= 12 F <= 12 F 12 B <= 12 B 12 print('AMBIGUOUS') print 'AMBIGUOUS' elif F > 12 and B <= 12:
    print('YYMM') F > 12 and B <= 12 F > 12 F 12 B <= 12 B 12 print('YYMM') print 'YYMM' elif F <= 12 and B > 12:
    print('MMYY') F <= 12 and B > 12 F <= 12 F 12 B > 12 B 12 print('MMYY') print 'MMYY' print('NA') print 'NA' S = input() input() S F = int(S[:2]) int(S[:2]) F B = int(S[2:]) int(S[2:]) B
S = input()

F = int(S[:2])
B = int(S[2:])

if F == 0 and B == 0:
    print('NA')
elif (F == 0 and B > 12) or (B == 0 and F > 12):
    print('NA')
elif F == 0:
    print('YYMM')
elif B == 0:
    print('MMYY')
elif (F <= 12 and B <= 12):
    print('AMBIGUOUS')
elif F > 12 and B <= 12:
    print('YYMM')
elif F <= 12 and B > 12:
    print('MMYY')
else:
    print('NA')
