s=input()
ans=[0]*2
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12:
    ans[0]=1
if 1<=b<=12:
    ans[1]=1

if ans[0]==ans[1]==1:
    print('AMBIGUOUS')
elif ans[0]==ans[1]==0:
    print('NA')
elif ans[0]==1 and ans[1]==0:
    print('MMYY')
else:
    print('YYMM') s=input() s input() input ans=[0]*2 ans [0]*2 [0] 0 2 a=int(s[:2]) a int(s[:2]) int s[:2] s :2 2 b=int(s[2:]) b int(s[2:]) int s[2:] s 2: 2 if 1<=a<=12:
    ans[0]=1 1<=a<=12 1<=a 1 a 12 ans[0]=1 ans[0] ans 0 1 if 1<=b<=12:
    ans[1]=1 1<=b<=12 1<=b 1 b 12 ans[1]=1 ans[1] ans 1 1 if ans[0]==ans[1]==1:
    print('AMBIGUOUS')
elif ans[0]==ans[1]==0:
    print('NA')
elif ans[0]==1 and ans[1]==0:
    print('MMYY')
else:
    print('YYMM') ans[0]==ans[1]==1 ans[0]==ans[1] ans[0] ans 0 ans[1] ans 1 1 print('AMBIGUOUS') print 'AMBIGUOUS' elif ans[0]==ans[1]==0:
    print('NA') ans[0]==ans[1]==0 ans[0]==ans[1] ans[0] ans 0 ans[1] ans 1 0 print('NA') print 'NA' elif ans[0]==1 and ans[1]==0:
    print('MMYY') ans[0]==1 and ans[1]==0 ans[0]==1 ans[0] ans 0 1 ans[1]==0 ans[1] ans 1 0 print('MMYY') print 'MMYY' print('YYMM') print 'YYMM' s=input() input() s a=int(s[:2]) int(s[:2]) a b=int(s[2:]) int(s[2:]) b ans=[0]*2 [0]*2 ans
s=input()
ans=[0]*2
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12:
    ans[0]=1
if 1<=b<=12:
    ans[1]=1

if ans[0]==ans[1]==1:
    print('AMBIGUOUS')
elif ans[0]==ans[1]==0:
    print('NA')
elif ans[0]==1 and ans[1]==0:
    print('MMYY')
else:
    print('YYMM')