S=input()
first = S[:2]
second= S[2:]
ans=""


if int(first) > 12 or int(first) == 0:#MM
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="YYMM"
	if int(second) > 12 or int(second) == 0:#YY
		ans="NA"

elif int(first) <= 12 and int(first) >= 1:#YY
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="AMBIGUOUS"
	if int(second) > 12 or int(second) == 0:#YY
		ans="MMYY"

print(ans) S=input() S input() input first = S[:2] first S[:2] S :2 2 second= S[2:] second S[2:] S 2: 2 ans="" ans "" if int(first) > 12 or int(first) == 0:#MM
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="YYMM"
	if int(second) > 12 or int(second) == 0:#YY
		ans="NA"

elif int(first) <= 12 and int(first) >= 1:#YY
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="AMBIGUOUS"
	if int(second) > 12 or int(second) == 0:#YY
		ans="MMYY" int(first) > 12 or int(first) == 0 int(first) > 12 int(first) int first 12 int(first) == 0 int(first) int first 0 if int(second) <= 12 and int(second) >= 1:#YY
		ans="YYMM"
	 int(second) <= 12 and int(second) >= 1 int(second) <= 12 int(second) int second 12 int(second) >= 1 int(second) int second 1 ans="YYMM" ans "YYMM" if int(second) > 12 or int(second) == 0:#YY
		ans="NA" int(second) > 12 or int(second) == 0 int(second) > 12 int(second) int second 12 int(second) == 0 int(second) int second 0 ans="NA" ans "NA" elif int(first) <= 12 and int(first) >= 1:#YY
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="AMBIGUOUS"
	if int(second) > 12 or int(second) == 0:#YY
		ans="MMYY" int(first) <= 12 and int(first) >= 1 int(first) <= 12 int(first) int first 12 int(first) >= 1 int(first) int first 1 if int(second) <= 12 and int(second) >= 1:#YY
		ans="AMBIGUOUS"
	 int(second) <= 12 and int(second) >= 1 int(second) <= 12 int(second) int second 12 int(second) >= 1 int(second) int second 1 ans="AMBIGUOUS" ans "AMBIGUOUS" if int(second) > 12 or int(second) == 0:#YY
		ans="MMYY" int(second) > 12 or int(second) == 0 int(second) > 12 int(second) int second 12 int(second) == 0 int(second) int second 0 ans="MMYY" ans "MMYY" print(ans) print ans first = S[:2] S[:2] first ans="" "" ans ans="NA" "NA" ans ans="YYMM" "YYMM" ans ans="MMYY" "MMYY" ans S=input() input() S second= S[2:] S[2:] second ans="AMBIGUOUS" "AMBIGUOUS" ans
S=input()
first = S[:2]
second= S[2:]
ans=""


if int(first) > 12 or int(first) == 0:#MM
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="YYMM"
	if int(second) > 12 or int(second) == 0:#YY
		ans="NA"

elif int(first) <= 12 and int(first) >= 1:#YY
	if int(second) <= 12 and int(second) >= 1:#YY
		ans="AMBIGUOUS"
	if int(second) > 12 or int(second) == 0:#YY
		ans="MMYY"

print(ans)