S = input()
S_front = S[:2]
S_back = S[2:]

if 0 < int(S_front) < 13:
	if 0 < int(S_back) < 13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 0 < int(S_back) < 13:
		print("YYMM")
	else:
		print("NA") S = input() S input() input S_front = S[:2] S_front S[:2] S :2 2 S_back = S[2:] S_back S[2:] S 2: 2 if 0 < int(S_front) < 13:
	if 0 < int(S_back) < 13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 0 < int(S_back) < 13:
		print("YYMM")
	else:
		print("NA") 0 < int(S_front) < 13 0 < int(S_front) 0 int(S_front) int S_front 13 if 0 < int(S_back) < 13:
		print("AMBIGUOUS")
	else:
		print("MMYY") 0 < int(S_back) < 13 0 < int(S_back) 0 int(S_back) int S_back 13 print("AMBIGUOUS") print "AMBIGUOUS" print("MMYY") print "MMYY" if 0 < int(S_back) < 13:
		print("YYMM")
	else:
		print("NA") 0 < int(S_back) < 13 0 < int(S_back) 0 int(S_back) int S_back 13 print("YYMM") print "YYMM" print("NA") print "NA" S = input() input() S S_back = S[2:] S[2:] S_back S_front = S[:2] S[:2] S_front
S = input()
S_front = S[:2]
S_back = S[2:]

if 0 < int(S_front) < 13:
	if 0 < int(S_back) < 13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 0 < int(S_back) < 13:
		print("YYMM")
	else:
		print("NA")