s = eval(input())

s1, s2 = int(s[:2]), int(s[2:])

ans = ['NA', 'YYMM', 'MMYY', 'AMBIGUOUS']

print((ans[((1 <= s1 <= 12) << 1) + (1 <= s2 <= 12)]))
s = eval(input())

b1 = 1 <= int(s[:2]) <= 12

b2 = 1 <= int(s[2:]) <= 12

ans = ['NA', 'YYMM', 'MMYY', 'AMBIGUOUS']

print((ans[2*b1 + b2]))
s = eval(input())
s1, s2 = int(s[:2]), int(s[2:])
ans = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
print((ans[((1 <= s1 <= 12) << 1) + (1 <= s2 <= 12)]))

s = eval(input())
b1 = 1 <= int(s[:2]) <= 12
b2 = 1 <= int(s[2:]) <= 12
ans = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
print((ans[2 * b1 + b2]))

-s1, s2 = int(s[:2]), int(s[2:]) +b1 = 1 <= int(s[:2]) <= 12 +b2 = 1 <= int(s[2:]) <= 12 -print((ans[((1 <= s1 <= 12) << 1) + (1 <= s2 <= 12)])) +print((ans[2 * b1 + b2]))