S = input()
L = int(S[0:2])
R = int(S[2:4])
if 0 < L <= 12 and 0 < R <= 12:
    print("AMBIGUOUS")
elif 0 < L <= 12:
    print("MMYY")
elif 0 < R <= 12:
    print("YYMM")
else:
    print("NA") S = input() S input() input L = int(S[0:2]) L int(S[0:2]) int S[0:2] S 0:2 0 2 R = int(S[2:4]) R int(S[2:4]) int S[2:4] S 2:4 2 4 if 0 < L <= 12 and 0 < R <= 12:
    print("AMBIGUOUS")
elif 0 < L <= 12:
    print("MMYY")
elif 0 < R <= 12:
    print("YYMM")
else:
    print("NA") 0 < L <= 12 and 0 < R <= 12 0 < L <= 12 0 < L 0 L 12 0 < R <= 12 0 < R 0 R 12 print("AMBIGUOUS") print "AMBIGUOUS" elif 0 < L <= 12:
    print("MMYY") 0 < L <= 12 0 < L 0 L 12 print("MMYY") print "MMYY" elif 0 < R <= 12:
    print("YYMM") 0 < R <= 12 0 < R 0 R 12 print("YYMM") print "YYMM" print("NA") print "NA" L = int(S[0:2]) int(S[0:2]) L S = input() input() S R = int(S[2:4]) int(S[2:4]) R
S = input()
L = int(S[0:2])
R = int(S[2:4])
if 0 < L <= 12 and 0 < R <= 12:
    print("AMBIGUOUS")
elif 0 < L <= 12:
    print("MMYY")
elif 0 < R <= 12:
    print("YYMM")
else:
    print("NA")