s = input()
a = int(s[:2])
b = int(s[2:])
if 0 < a and a<13:
    if 0<b and b<13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0<b and b<13:
    print('YYMM')
else:
    print('NA') s = input() s input() input a = int(s[:2]) a int(s[:2]) int s[:2] s :2 2 b = int(s[2:]) b int(s[2:]) int s[2:] s 2: 2 if 0 < a and a<13:
    if 0<b and b<13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0<b and b<13:
    print('YYMM')
else:
    print('NA') 0 < a and a<13 0 < a 0 a a<13 a 13 if 0<b and b<13:
        print('AMBIGUOUS')
    else:
        print('MMYY') 0<b and b<13 0<b 0 b b<13 b 13 print('AMBIGUOUS') print 'AMBIGUOUS' print('MMYY') print 'MMYY' elif 0<b and b<13:
    print('YYMM') 0<b and b<13 0<b 0 b b<13 b 13 print('YYMM') print 'YYMM' print('NA') print 'NA' s = input() input() s a = int(s[:2]) int(s[:2]) a b = int(s[2:]) int(s[2:]) b
s = input()
a = int(s[:2])
b = int(s[2:])
if 0 < a and a<13:
    if 0<b and b<13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0<b and b<13:
    print('YYMM')
else:
    print('NA')