s = input()
ans = [0,0]
if 1 <=  int(s[:2]) <= 12:
    ans[0] = 1
if 1 <= int(s[2:]) <= 12:
    ans[1] = 1
print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][ans[0]][ans[1]]) s = input() s input() input ans = [0,0] ans [0,0] 0 0 if 1 <=  int(s[:2]) <= 12:
    ans[0] = 1 1 <=  int(s[:2]) <= 12 1 <=  int(s[:2]) 1 int(s[:2]) int s[:2] s :2 2 12 ans[0] = 1 ans[0] ans 0 1 if 1 <= int(s[2:]) <= 12:
    ans[1] = 1 1 <= int(s[2:]) <= 12 1 <= int(s[2:]) 1 int(s[2:]) int s[2:] s 2: 2 12 ans[1] = 1 ans[1] ans 1 1 print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][ans[0]][ans[1]]) print [["NA","YYMM"],["MMYY","AMBIGUOUS"]][ans[0]][ans[1]] [ans[0]] [["NA","YYMM"],["MMYY","AMBIGUOUS"]] ["NA","YYMM"] "NA" "YYMM" ["MMYY","AMBIGUOUS"] "MMYY" "AMBIGUOUS" ans[0] ans 0 ans[1] ans 1 s = input() input() s ans = [0,0] [0,0] ans
s = input()
ans = [0,0]
if 1 <=  int(s[:2]) <= 12:
    ans[0] = 1
if 1 <= int(s[2:]) <= 12:
    ans[1] = 1
print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][ans[0]][ans[1]])