s=input()
s1=s[0]+s[1]
s2=s[2]+s[3]
n1=int(s1)
n2=int(s2)
if 1<=n1<=12:
    if 1<=n2<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=n2<=12:
        print('YYMM')
    else:
        print('NA') s=input() s input() input s1=s[0]+s[1] s1 s[0]+s[1] s[0] s 0 s[1] s 1 s2=s[2]+s[3] s2 s[2]+s[3] s[2] s 2 s[3] s 3 n1=int(s1) n1 int(s1) int s1 n2=int(s2) n2 int(s2) int s2 if 1<=n1<=12:
    if 1<=n2<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=n2<=12:
        print('YYMM')
    else:
        print('NA') 1<=n1<=12 1<=n1 1 n1 12 if 1<=n2<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY') 1<=n2<=12 1<=n2 1 n2 12 print('AMBIGUOUS') print 'AMBIGUOUS' print('MMYY') print 'MMYY' if 1<=n2<=12:
        print('YYMM')
    else:
        print('NA') 1<=n2<=12 1<=n2 1 n2 12 print('YYMM') print 'YYMM' print('NA') print 'NA' n2=int(s2) int(s2) n2 s1=s[0]+s[1] s[0]+s[1] s1 s2=s[2]+s[3] s[2]+s[3] s2 n1=int(s1) int(s1) n1 s=input() input() s
s=input()
s1=s[0]+s[1]
s2=s[2]+s[3]
n1=int(s1)
n2=int(s2)
if 1<=n1<=12:
    if 1<=n2<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=n2<=12:
        print('YYMM')
    else:
        print('NA')