x = input()
a, b = int(x[0:2]), int(x[2:4])
flag = 0
ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"]

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0):
    flag = 3
elif ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)):
    flag = 2
elif ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)):
    flag = 1


print(ans[flag]) x = input() x input() input a, b = int(x[0:2]), int(x[2:4]) a int(x[0:2]) int x[0:2] x 0:2 0 2 b int(x[2:4]) int x[2:4] x 2:4 2 4 flag = 0 flag 0 ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"] ans ["AMBIGUOUS", "YYMM", "MMYY", "NA"] "AMBIGUOUS" "YYMM" "MMYY" "NA" if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0):
    flag = 3
elif ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)):
    flag = 2
elif ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)):
    flag = 1 (a >= 1 and a <= 12) and (b >= 1 and b <= 12) a >= 1 and a <= 12 a >= 1 a 1 a <= 12 a 12 b >= 1 and b <= 12 b >= 1 b 1 b <= 12 b 12 flag = 0 flag 0 elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0):
    flag = 3 (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0) (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) (a == 0 and b > 12) or (b == 0 and a > 12) a == 0 and b > 12 a == 0 a 0 b > 12 b 12 b == 0 and a > 12 b == 0 b 0 a > 12 a 12 b > 12 and a > 12 b > 12 b 12 a > 12 a 12 b == 0 and a == 0 b == 0 b 0 a == 0 a 0 flag = 3 flag 3 elif ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)):
    flag = 2 ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)) (a > 0 and a <= 12) and (b >= 13) a > 0 and a <= 12 a > 0 a 0 a <= 12 a 12 b >= 13 b 13 b == 0 and (a >= 1 and a <= 12) b == 0 b 0 a >= 1 and a <= 12 a >= 1 a 1 a <= 12 a 12 flag = 2 flag 2 elif ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)):
    flag = 1 ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)) (a >= 13) and (b > 0 and b <= 12) a >= 13 a 13 b > 0 and b <= 12 b > 0 b 0 b <= 12 b 12 a == 0 and (b >= 1 and b <= 12) a == 0 a 0 b >= 1 and b <= 12 b >= 1 b 1 b <= 12 b 12 flag = 1 flag 1 print(ans[flag]) print ans[flag] ans flag flag = 0 0 flag flag = 0 0 flag flag = 1 1 flag x = input() input() x flag = 3 3 flag flag = 2 2 flag ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"] ["AMBIGUOUS", "YYMM", "MMYY", "NA"] ans b = int(x[0:2]), int(x[2:4]) int(x[2:4]) b a, b = int(x[0:2]), int(x[2:4]) int(x[0:2]) a
x = input()
a, b = int(x[0:2]), int(x[2:4])
flag = 0
ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"]

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0):
    flag = 3
elif ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)):
    flag = 2
elif ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)):
    flag = 1


print(ans[flag])
