#ABC126 B

S = list(map(int,input()))
if 1 <= S[0]*10 + S[1] <= 12 and 1 <= S[2]*10 + S[3] <= 12:
    print("AMBIGUOUS")
elif 1 <= S[0]*10 + S[1] <= 12 and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("MMYY")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0)  and  1 <= S[2]*10 + S[3] <= 12:
    print("YYMM")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0) and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("NA") S = list(map(int,input())) S list(map(int,input())) list map(int,input()) map int input() input if 1 <= S[0]*10 + S[1] <= 12 and 1 <= S[2]*10 + S[3] <= 12:
    print("AMBIGUOUS")
elif 1 <= S[0]*10 + S[1] <= 12 and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("MMYY")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0)  and  1 <= S[2]*10 + S[3] <= 12:
    print("YYMM")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0) and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("NA") 1 <= S[0]*10 + S[1] <= 12 and 1 <= S[2]*10 + S[3] <= 12 1 <= S[0]*10 + S[1] <= 12 1 <= S[0]*10 + S[1] 1 S[0]*10 + S[1] S[0]*10 S[0] S 0 10 S[1] S 1 12 1 <= S[2]*10 + S[3] <= 12 1 <= S[2]*10 + S[3] 1 S[2]*10 + S[3] S[2]*10 S[2] S 2 10 S[3] S 3 12 print("AMBIGUOUS") print "AMBIGUOUS" elif 1 <= S[0]*10 + S[1] <= 12 and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("MMYY") 1 <= S[0]*10 + S[1] <= 12 and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0) 1 <= S[0]*10 + S[1] <= 12 1 <= S[0]*10 + S[1] 1 S[0]*10 + S[1] S[0]*10 S[0] S 0 10 S[1] S 1 12 S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0 S[2]*10 + S[3] > 12 S[2]*10 + S[3] S[2]*10 S[2] S 2 10 S[3] S 3 12 S[2]*10 + S[3] == 0 S[2]*10 + S[3] S[2]*10 S[2] S 2 10 S[3] S 3 0 print("MMYY") print "MMYY" elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0)  and  1 <= S[2]*10 + S[3] <= 12:
    print("YYMM") (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0)  and  1 <= S[2]*10 + S[3] <= 12 S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0 S[0]*10 + S[1] > 12 S[0]*10 + S[1] S[0]*10 S[0] S 0 10 S[1] S 1 12 S[0]*10 + S[1] == 0 S[0]*10 + S[1] S[0]*10 S[0] S 0 10 S[1] S 1 0 1 <= S[2]*10 + S[3] <= 12 1 <= S[2]*10 + S[3] 1 S[2]*10 + S[3] S[2]*10 S[2] S 2 10 S[3] S 3 12 print("YYMM") print "YYMM" elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0) and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("NA") (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0) and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0) S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0 S[0]*10 + S[1] > 12 S[0]*10 + S[1] S[0]*10 S[0] S 0 10 S[1] S 1 12 S[0]*10 + S[1] == 0 S[0]*10 + S[1] S[0]*10 S[0] S 0 10 S[1] S 1 0 S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0 S[2]*10 + S[3] > 12 S[2]*10 + S[3] S[2]*10 S[2] S 2 10 S[3] S 3 12 S[2]*10 + S[3] == 0 S[2]*10 + S[3] S[2]*10 S[2] S 2 10 S[3] S 3 0 print("NA") print "NA" S = list(map(int,input())) list(map(int,input())) S
#ABC126 B

S = list(map(int,input()))
if 1 <= S[0]*10 + S[1] <= 12 and 1 <= S[2]*10 + S[3] <= 12:
    print("AMBIGUOUS")
elif 1 <= S[0]*10 + S[1] <= 12 and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("MMYY")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0)  and  1 <= S[2]*10 + S[3] <= 12:
    print("YYMM")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0) and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("NA")