S=input()
a=1<=int(S[:2])<=12
b=1<=int(S[-2:])<=12

if a & b: print('AMBIGUOUS')
elif a:   print('MMYY')
elif b:   print('YYMM')
else:     print('NA') S=input() S input() input a=1<=int(S[:2])<=12 a 1<=int(S[:2])<=12 1<=int(S[:2]) 1 int(S[:2]) int S[:2] S :2 2 12 b=1<=int(S[-2:])<=12 b 1<=int(S[-2:])<=12 1<=int(S[-2:]) 1 int(S[-2:]) int S[-2:] S -2: -2 12 if a & b: print('AMBIGUOUS')
elif a:   print('MMYY')
elif b:   print('YYMM')
else:     print('NA') a & b a b elif a:   print('MMYY') a elif b:   print('YYMM') b S=input() input() S a=1<=int(S[:2])<=12 1<=int(S[:2])<=12 a b=1<=int(S[-2:])<=12 1<=int(S[-2:])<=12 b
S=input()
a=1<=int(S[:2])<=12
b=1<=int(S[-2:])<=12

if a & b: print('AMBIGUOUS')
elif a:   print('MMYY')
elif b:   print('YYMM')
else:     print('NA')