S=input()
x=int(S[:2])
y=int(S[2:])

if 0<x<13 and 0<y<13:print("AMBIGUOUS")
elif 0<x<13:print("MMYY")
elif 0<y<13:print("YYMM")
else:print("NA") S=input() S input() input x=int(S[:2]) x int(S[:2]) int S[:2] S :2 2 y=int(S[2:]) y int(S[2:]) int S[2:] S 2: 2 if 0<x<13 and 0<y<13:print("AMBIGUOUS")
elif 0<x<13:print("MMYY")
elif 0<y<13:print("YYMM")
else:print("NA") 0<x<13 and 0<y<13 0<x<13 0<x 0 x 13 0<y<13 0<y 0 y 13 elif 0<x<13:print("MMYY") 0<x<13 0<x 0 x 13 elif 0<y<13:print("YYMM") 0<y<13 0<y 0 y 13 y=int(S[2:]) int(S[2:]) y S=input() input() S x=int(S[:2]) int(S[:2]) x
S=input()
x=int(S[:2])
y=int(S[2:])

if 0<x<13 and 0<y<13:print("AMBIGUOUS")
elif 0<x<13:print("MMYY")
elif 0<y<13:print("YYMM")
else:print("NA")