s = input()

b = int(s[:2])
a = int(s[2:])

def yorm(i):
    flag = 'none'
    if 0<i<=12:
        flag = 'MM'
    elif i<100:
        flag = 'YY'
    return flag

bf = yorm(b)
af = yorm(a)
   
ans = bf+af
if len(ans) != 4:
    ans = 'NA'
if ans == 'MMMM':
    ans = 'AMBIGUOUS'
if ans == 'YYYY':
    ans = 'NA'
print(ans) s = input() s input() input b = int(s[:2]) b int(s[:2]) int s[:2] s :2 2 a = int(s[2:]) a int(s[2:]) int s[2:] s 2: 2 def yorm(i):
    flag = 'none'
    if 0<i<=12:
        flag = 'MM'
    elif i<100:
        flag = 'YY'
    return flag yorm flag = 'none' flag 'none' if 0<i<=12:
        flag = 'MM'
    elif i<100:
        flag = 'YY'
     0<i<=12 0<i 0 i 12 flag = 'MM' flag 'MM' elif i<100:
        flag = 'YY'
     i<100 i 100 flag = 'YY' flag 'YY' return flag flag i i bf = yorm(b) bf yorm(b) yorm b af = yorm(a) af yorm(a) yorm a ans = bf+af ans bf+af bf af if len(ans) != 4:
    ans = 'NA' len(ans) != 4 len(ans) len ans 4 ans = 'NA' ans 'NA' if ans == 'MMMM':
    ans = 'AMBIGUOUS' ans == 'MMMM' ans 'MMMM' ans = 'AMBIGUOUS' ans 'AMBIGUOUS' if ans == 'YYYY':
    ans = 'NA' ans == 'YYYY' ans 'YYYY' ans = 'NA' ans 'NA' print(ans) print ans a = int(s[2:]) int(s[2:]) a ans = 'AMBIGUOUS' 'AMBIGUOUS' ans bf = yorm(b) yorm(b) bf ans = 'NA' 'NA' ans ans = 'NA' 'NA' ans s = input() input() s ans = bf+af bf+af ans def yorm(i):
    flag = 'none'
    if 0<i<=12:
        flag = 'MM'
    elif i<100:
        flag = 'YY'
    return flag def yorm(i):
    flag = 'none'
    if 0<i<=12:
        flag = 'MM'
    elif i<100:
        flag = 'YY'
    return flag yorm b = int(s[:2]) int(s[:2]) b af = yorm(a) yorm(a) af
s = input()

b = int(s[:2])
a = int(s[2:])

def yorm(i):
    flag = 'none'
    if 0<i<=12:
        flag = 'MM'
    elif i<100:
        flag = 'YY'
    return flag

bf = yorm(b)
af = yorm(a)
   
ans = bf+af
if len(ans) != 4:
    ans = 'NA'
if ans == 'MMMM':
    ans = 'AMBIGUOUS'
if ans == 'YYYY':
    ans = 'NA'
print(ans)