s=input()
t,u=0<int(s[:2])<13,0<int(s[2:])<13
print('AMBIGUOUS' if t and u else 'MMYY' if t else 'YYMM' if u else 'NA') s=input() s input() input t,u=0<int(s[:2])<13,0<int(s[2:])<13 t 0<int(s[:2])<13 0<int(s[:2]) 0 int(s[:2]) int s[:2] s :2 2 13 u 0<int(s[2:])<13 0<int(s[2:]) 0 int(s[2:]) int s[2:] s 2: 2 13 print('AMBIGUOUS' if t and u else 'MMYY' if t else 'YYMM' if u else 'NA') print 'AMBIGUOUS' if t and u else 'MMYY' if t else 'YYMM' if u else 'NA' t and u t u 'AMBIGUOUS' 'MMYY' if t else 'YYMM' if u else 'NA' t 'MMYY' 'YYMM' if u else 'NA' u 'YYMM' 'NA' u=0<int(s[:2])<13,0<int(s[2:])<13 0<int(s[2:])<13 u s=input() input() s t,u=0<int(s[:2])<13,0<int(s[2:])<13 0<int(s[:2])<13 t
s=input()
t,u=0<int(s[:2])<13,0<int(s[2:])<13
print('AMBIGUOUS' if t and u else 'MMYY' if t else 'YYMM' if u else 'NA')
