S = input()
ans = [0,0]

if 1<=int(S[:2]) and int(S[:2]) <= 12 :
    ans[0] = 1
if 1 <=int(S[2:]) and int(S[2:]) <= 12 :
    ans[1] = 1

if ans == [1,1] :
    print('AMBIGUOUS')
elif ans == [0,0] :
    print('NA')
elif ans == [0,1] :
    print('YYMM')
elif ans == [1,0] :
    print('MMYY') S = input() S input() input ans = [0,0] ans [0,0] 0 0 if 1<=int(S[:2]) and int(S[:2]) <= 12 :
    ans[0] = 1 1<=int(S[:2]) and int(S[:2]) <= 12 1<=int(S[:2]) 1 int(S[:2]) int S[:2] S :2 2 int(S[:2]) <= 12 int(S[:2]) int S[:2] S :2 2 12 ans[0] = 1 ans[0] ans 0 1 if 1 <=int(S[2:]) and int(S[2:]) <= 12 :
    ans[1] = 1 1 <=int(S[2:]) and int(S[2:]) <= 12 1 <=int(S[2:]) 1 int(S[2:]) int S[2:] S 2: 2 int(S[2:]) <= 12 int(S[2:]) int S[2:] S 2: 2 12 ans[1] = 1 ans[1] ans 1 1 if ans == [1,1] :
    print('AMBIGUOUS')
elif ans == [0,0] :
    print('NA')
elif ans == [0,1] :
    print('YYMM')
elif ans == [1,0] :
    print('MMYY') ans == [1,1] ans [1,1] 1 1 print('AMBIGUOUS') print 'AMBIGUOUS' elif ans == [0,0] :
    print('NA') ans == [0,0] ans [0,0] 0 0 print('NA') print 'NA' elif ans == [0,1] :
    print('YYMM') ans == [0,1] ans [0,1] 0 1 print('YYMM') print 'YYMM' elif ans == [1,0] :
    print('MMYY') ans == [1,0] ans [1,0] 1 0 print('MMYY') print 'MMYY' S = input() input() S ans = [0,0] [0,0] ans
S = input()
ans = [0,0]

if 1<=int(S[:2]) and int(S[:2]) <= 12 :
    ans[0] = 1
if 1 <=int(S[2:]) and int(S[2:]) <= 12 :
    ans[1] = 1

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