s = list(map(int,list(input())))
a = s[0]*10+s[1]
b = s[2]*10+s[3]
if a == 0 and b == 0:
    print('NA')
    exit()
if 0 < a<= 12 and (b>12 or b==0):
    print('MMYY')
elif (a > 12 or a==0) and 0 < b <= 12:
    print('YYMM')
elif a <= 12 and b <= 12:
    print('AMBIGUOUS')
else:print('NA') s = list(map(int,list(input()))) s list(map(int,list(input()))) list map(int,list(input())) map int list(input()) list input() input a = s[0]*10+s[1] a s[0]*10+s[1] s[0]*10 s[0] s 0 10 s[1] s 1 b = s[2]*10+s[3] b s[2]*10+s[3] s[2]*10 s[2] s 2 10 s[3] s 3 if a == 0 and b == 0:
    print('NA')
    exit() a == 0 and b == 0 a == 0 a 0 b == 0 b 0 print('NA') print 'NA' exit() exit if 0 < a<= 12 and (b>12 or b==0):
    print('MMYY')
elif (a > 12 or a==0) and 0 < b <= 12:
    print('YYMM')
elif a <= 12 and b <= 12:
    print('AMBIGUOUS')
else:print('NA') 0 < a<= 12 and (b>12 or b==0) 0 < a<= 12 0 < a 0 a 12 b>12 or b==0 b>12 b 12 b==0 b 0 print('MMYY') print 'MMYY' elif (a > 12 or a==0) and 0 < b <= 12:
    print('YYMM') (a > 12 or a==0) and 0 < b <= 12 a > 12 or a==0 a > 12 a 12 a==0 a 0 0 < b <= 12 0 < b 0 b 12 print('YYMM') print 'YYMM' elif a <= 12 and b <= 12:
    print('AMBIGUOUS') a <= 12 and b <= 12 a <= 12 a 12 b <= 12 b 12 print('AMBIGUOUS') print 'AMBIGUOUS' s = list(map(int,list(input()))) list(map(int,list(input()))) s b = s[2]*10+s[3] s[2]*10+s[3] b a = s[0]*10+s[1] s[0]*10+s[1] a
s = list(map(int,list(input())))
a = s[0]*10+s[1]
b = s[2]*10+s[3]
if a == 0 and b == 0:
    print('NA')
    exit()
if 0 < a<= 12 and (b>12 or b==0):
    print('MMYY')
elif (a > 12 or a==0) and 0 < b <= 12:
    print('YYMM')
elif a <= 12 and b <= 12:
    print('AMBIGUOUS')
else:print('NA')