S = input()
ANS = {0:'NA', 1:'YYMM', 2:'MMYY', 3:'AMBIGUOUS'}
ans = 0
if '00' <= S[:2] <= '99' and '01' <= S[2:] <= '12':
    ans += 1
if '00' <= S[2:] <= '99' and '01' <= S[:2] <= '12':
    ans += 2
print(ANS[ans]) S = input() S input() input ANS = {0:'NA', 1:'YYMM', 2:'MMYY', 3:'AMBIGUOUS'} ANS {0:'NA', 1:'YYMM', 2:'MMYY', 3:'AMBIGUOUS'} 0 0 'NA' 1 1 'YYMM' 2 2 'MMYY' 3 3 'AMBIGUOUS' ans = 0 ans 0 if '00' <= S[:2] <= '99' and '01' <= S[2:] <= '12':
    ans += 1 '00' <= S[:2] <= '99' and '01' <= S[2:] <= '12' '00' <= S[:2] <= '99' '00' <= S[:2] '00' S[:2] S :2 2 '99' '01' <= S[2:] <= '12' '01' <= S[2:] '01' S[2:] S 2: 2 '12' ans += 1 ans 1 if '00' <= S[2:] <= '99' and '01' <= S[:2] <= '12':
    ans += 2 '00' <= S[2:] <= '99' and '01' <= S[:2] <= '12' '00' <= S[2:] <= '99' '00' <= S[2:] '00' S[2:] S 2: 2 '99' '01' <= S[:2] <= '12' '01' <= S[:2] '01' S[:2] S :2 2 '12' ans += 2 ans 2 print(ANS[ans]) print ANS[ans] ANS ans ans += 1 1 ans ans += 2 2 ans S = input() input() S ans = 0 0 ans ANS = {0:'NA', 1:'YYMM', 2:'MMYY', 3:'AMBIGUOUS'} {0:'NA', 1:'YYMM', 2:'MMYY', 3:'AMBIGUOUS'} ANS
S = input()
ANS = {0:'NA', 1:'YYMM', 2:'MMYY', 3:'AMBIGUOUS'}
ans = 0
if '00' <= S[:2] <= '99' and '01' <= S[2:] <= '12':
    ans += 1
if '00' <= S[2:] <= '99' and '01' <= S[:2] <= '12':
    ans += 2
print(ANS[ans])
