s = eval(input())

ans = {(False, False): 'NA', (False, True): 'YYMM', (True, False): 'MMYY', (True, True): 'AMBIGUOUS'}

print((ans[1 <= int(s[:2]) <= 12, 1 <= int(s[2:]) <= 12]))
s = eval(input())

F, T = False, True

ans = {(F, F): 'NA', (F, T): 'YYMM', (T, F): 'MMYY', (T, T): 'AMBIGUOUS'}

print((ans[1 <= int(s[:2]) <= 12, 1 <= int(s[2:]) <= 12]))
s = eval(input())
ans = {
    (False, False): "NA",
    (False, True): "YYMM",
    (True, False): "MMYY",
    (True, True): "AMBIGUOUS",
}
print((ans[1 <= int(s[:2]) <= 12, 1 <= int(s[2:]) <= 12]))

s = eval(input())
F, T = False, True
ans = {(F, F): "NA", (F, T): "YYMM", (T, F): "MMYY", (T, T): "AMBIGUOUS"}
print((ans[1 <= int(s[:2]) <= 12, 1 <= int(s[2:]) <= 12]))

-ans = { -    (False, False): "NA", -    (False, True): "YYMM", -    (True, False): "MMYY", -    (True, True): "AMBIGUOUS", -} +F, T = False, True +ans = {(F, F): "NA", (F, T): "YYMM", (T, F): "MMYY", (T, T): "AMBIGUOUS"}