s = input()
a = int(s[0:2])
b = int(s[2:])

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

if 13 <= a or a == 0:
    if 1 <= b and b <= 12:
        print('YYMM')
    else:
        print('NA')
else:
    
    if 1<= b  and b<= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')