s = input()

f = (0 < int(s[:2]) < 13)
s = (0 < int(s[2:]) < 13)
ans = 'NA'
if f and s:
    ans = 'AMBIGUOUS'
elif s:
    ans = 'YYMM'
elif f:
    ans = 'MMYY'
print(ans) s = input() s input() input f = (0 < int(s[:2]) < 13) f 0 < int(s[:2]) < 13 0 < int(s[:2]) 0 int(s[:2]) int s[:2] s :2 2 13 s = (0 < int(s[2:]) < 13) s 0 < int(s[2:]) < 13 0 < int(s[2:]) 0 int(s[2:]) int s[2:] s 2: 2 13 ans = 'NA' ans 'NA' if f and s:
    ans = 'AMBIGUOUS'
elif s:
    ans = 'YYMM'
elif f:
    ans = 'MMYY' f and s f s ans = 'AMBIGUOUS' ans 'AMBIGUOUS' elif s:
    ans = 'YYMM' s ans = 'YYMM' ans 'YYMM' elif f:
    ans = 'MMYY' f ans = 'MMYY' ans 'MMYY' print(ans) print ans ans = 'YYMM' 'YYMM' ans ans = 'NA' 'NA' ans s = (0 < int(s[2:]) < 13) 0 < int(s[2:]) < 13 s ans = 'MMYY' 'MMYY' ans s = input() input() s f = (0 < int(s[:2]) < 13) 0 < int(s[:2]) < 13 f ans = 'AMBIGUOUS' 'AMBIGUOUS' ans
s = input()

f = (0 < int(s[:2]) < 13)
s = (0 < int(s[2:]) < 13)
ans = 'NA'
if f and s:
    ans = 'AMBIGUOUS'
elif s:
    ans = 'YYMM'
elif f:
    ans = 'MMYY'
print(ans)
