peterverebics/CodeNet_Python_118 huggingface dataset:
a = input()
if int(a[:2]) < 13 and int(a[:2]) > 0:
    if int(a[2:4]) < 13 and int(a[2:4]) > 0: print('AMBIGUOUS')
    else: print('MMYY')
elif int(a[2:]) < 13 and int(a[2:]) > 0: print('YYMM')
else: print('NA')
S = input()
ahead = S[0:2]
post = S[2:]

if (ahead == '00' or int(ahead) > 12):
    a_judge = True
else:
    a_judge = False

if (post == '00' or int(post) > 12):
    p_judge = True
else:
    p_judge = False

if (a_judge and p_judge):
    ans = 'NA'
elif (a_judge):
    ans = 'YYMM'
elif (p_judge):
    ans = 'MMYY'
else:
    ans = 'AMBIGUOUS'

print(ans)
s = input()
F = 0 < int(s[:2]) < 13
S = 0 < int(s[2:]) < 13
print("AMBIGUOUS" if F*S else "YYMM" if S else "MMYY" if F else "NA")
S = int(input())

L = S // 100 # 前半2桁
R = S % 100 # 後半2桁

if L > 12 or L == 0:
  if R > 12 or R == 0: print('NA')
  else: print('YYMM')
else:
  if R > 12 or R == 0: print('MMYY')
  else: print('AMBIGUOUS')
s = int(input())
a, b = s // 100, s % 100
x = "YY" if a == 0 or a > 12 else "MM"
y = "YY" if b == 0 or b > 12 else "MM"
if x != y:
    print(x + y)
else:
    print("NA" if x == "YY" else "AMBIGUOUS")
# 初期入力
import sys
input = sys.stdin.readline
S =input().strip()

s12 =int(S[:2])
s34 =int(S[2:])
mm=[1,2,3,4,5,6,7,8,9,10,11,12]
yy=[i for i in range(100)]
if s12 in yy and s12 in mm and s34 in yy and s34 in mm:
    print("AMBIGUOUS")
elif s12 in yy and s34 in mm:
    print("YYMM")
elif s12 in mm and s34 in yy :
    print("MMYY")
else:
    print("NA")
s = input()
firstHalf = s[:2]
secondHalf = s[2:]
val1 = 0
val2 = 0
if firstHalf[0] == '0':
    val1 = int(firstHalf[1])
else:
    val1 = int(firstHalf)
if secondHalf[0] == '0':
    val2 = int(secondHalf[1])
else:
    val2 = int(secondHalf)
first = False
second = False
if val1 <= 12 and val1 > 0:
    first = True
if val2 <= 12 and val2 > 0:
    second = True
if first and second:
    print("AMBIGUOUS")
elif first:
    print("MMYY")
elif second:
    print("YYMM")
else:
    print("NA")
s = input()
if 1 <= int(s[0:2]) <= 12:
  if 1 <= int(s[2:4]) <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= int(s[2:4]) <= 12:
    print("YYMM")
  else:
    print("NA")
s = input()
mmyy = (1 <= int(s[:2]) <= 12)
yymm = (1 <= int(s[2:]) <= 12)
if mmyy:
  if yymm:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if yymm:
    print('YYMM')
  else:
    print('NA')
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if s1 <= 12 and s2 <= 12 and s1 >= 1 and s2 >= 1:
    print('AMBIGUOUS')
elif s1 <= 12 and s1 >= 1:
    print('MMYY')
elif s2 <= 12 and s2 >= 1:
    print('YYMM')
else:
    print('NA')
s = str(input())
top = int(s[:2])
bottom = int(s[2:])

if 1 <= top <= 12 and 1 <= bottom <= 12:
    print('AMBIGUOUS')
elif top > 12 and bottom > 12:
    print('NA')
elif 1 <= top <= 12:
    print('MMYY')
elif 1 <= bottom <= 12:
    print('YYMM')
else:
    print('NA')
s=input()

YYMM=False
MMYY=False

month=[]
for i in range(1,13):
    if len(str(i))==1:
        month.append("0"+str(i))
    else:
        month.append(str(i))

if s[:2] in month:
    MMYY=True

if s[2:] in month:
    YYMM=True

if MMYY is True and YYMM is True:
    print("AMBIGUOUS")
elif  MMYY is True and YYMM is False:
    print("MMYY")
elif  MMYY is False and YYMM is True:
    print("YYMM")
else:
    print("NA")
s=input()
a=(int(s[0])-0)*10+int(s[1])
b=(int(s[2])-0)*10+int(s[3])
if 1<=b<=12 and (12<a or a==0):
    print("YYMM")
elif 1<=a<=12 and (12<b or b==0):
    print("MMYY")
elif 1<=a<=12 and 1<=b<=12: 
    print("AMBIGUOUS")
else:
    print("NA")
S=input()
Y=int(S[:2])
M=int(S[2:])
if Y==0 or Y>12:
    #Y!=MANTH
    if M==0 or M>12:
        print("NA")
    else:
        print("YYMM")
else:
    if M==0 or M>12:
        print("MMYY")
    else:
        print("AMBIGUOUS")
def main():
    S = input()
    first = S[:2]
    second = S[2:]
    YYMM = False
    MMYY = False

    if "00" <= first <= "99" and "01" <= second <= "12":
        YYMM = True
    if "01" <= first <= "12" and "00" <= second <= "99":
        MMYY = True

    if YYMM and MMYY:
        ans = "AMBIGUOUS"
    elif YYMM:
        ans = "YYMM"
    elif MMYY:
        ans = "MMYY"
    else:
        ans = "NA"

    print(ans)


if __name__ == "__main__":
    main()
S = input()
a = 0
b = 0
if (S[0] == '0' and S[1] != '0') or (S[0] == '1' and (S[1] == '0' or S[1] == '1' or S[1] == '2')):
  a = 1
if (S[2] == '0' and S[3] != '0') or (S[2] == '1' and (S[3] == '0' or S[3] == '1' or S[3] == '2')):
  b = 1
if a == 1 and b == 1:
  print("AMBIGUOUS")
elif a == 1:
  print("MMYY")
elif b == 1:
  print("YYMM")
else:
  print("NA")
s = list(input())

a = int(s[0]+s[1])
b = int(s[2]+s[3])

if  1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif (a>12 or a==0) and 1<=b<=12:
  print('YYMM')
elif (b>12 or b==0) and 1<=a<=12:
  print('MMYY')
elif (a>12 or a==0) and (b>12 or b==0):
  print('NA')
S=input()
a=int(S[0]+S[1])
b=int(S[2]+S[3])
if 0<a<13 and 0<b<13:
    print('AMBIGUOUS')
elif 0<a<13:
    print('MMYY')
elif 0<b<13:
    print('YYMM')
else:
    print('NA')
S = input()
F = int(S[0:2])
SE = int(S[2:4])


if F > 12 and 1 <= SE <= 12:
  print("YYMM")
elif 1 <= F <= 12 and SE > 12:
  print("MMYY")
elif 1 <= F <= 12 and 1 <= SE <= 12:
  print("AMBIGUOUS")
elif F == 0 and 1 <= SE <= 12:
  print("YYMM")
elif 1 <= F <= 12 and SE == 0:
  print("MMYY")
else:
  print("NA")
s = list(input())
head = int(s[0] + s[1])
tail = int(s[2] + s[3])
 
if (0 < head < 13) and (0 < tail < 13):
    print('AMBIGUOUS')
elif 0 < tail < 13:
    print('YYMM')
elif 0 < head < 13:
    print('MMYY')
else:
    print('NA')
s = input()
bit_pre = 0
bit_post = 0
if 1 <= int(s[:2]) and int(s[:2]) <= 12:
    bit_pre = 1
if 1 <= int(s[2:]) and int(s[2:]) <= 12:
    bit_post = 1
if bit_pre and bit_post:
    print("AMBIGUOUS")
elif bit_pre:
    print("MMYY")
elif bit_post:
    print("YYMM")
else:
    print("NA")
dList = list(str(input()))

former = int(''.join([dList[0],dList[1]]))
latter = int(''.join([dList[2],dList[3]]))

if 1 <= former <= 12: 
  if 1<= latter<= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif former > 12:
  if 1<= latter<= 12:
    print("YYMM")
  else:
    print("NA")
else:
  if latter == 0 or latter > 13:
    print("NA")
  else:
    print("YYMM")
S=input()
a=int(S[:2])
b=int(S[2:])
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")
import sys

s = sys.stdin.readline().rstrip()

def main():
    a, b = int(s[:2]), int(s[2:])
    if 1 <= a <= 12:
        if 1 <= b <= 12:
            return 'AMBIGUOUS'
        else:
            return 'MMYY'
    else:
        if 1 <= b <= 12:
            return 'YYMM'
        else:
            return 'NA'

if __name__ == '__main__':
    ans = main()
    print(ans)
S = input()

s1 = int(S[0:2])
s2 = int(S[2:4])

if 1 <= s1 <= 12 :
    if 1<= s2 <= 12:
        print("AMBIGUOUS")
    else :
        print("MMYY")
elif 1 <= s2 <= 12:
    print("YYMM")
else :
    print("NA")
s = input()
first = int(s[:2])
second = int(s[2:])
if 1 <= first <= 12:
  if 1 <= second <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= second <= 12:
    print('YYMM')
  else:
    print('NA')
S = input()

MM = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']

if S[0:2] in MM and S[2:4] in MM:
  print('AMBIGUOUS')
elif S[0:2] in MM:
  print('MMYY')
elif S[2:4] in MM:
  print('YYMM')
else:
  print('NA')
S=input()
s1=S[0:2]
s2=S[2:4]
li=["01","02","03","04","05","06","07","08","09","10","11","12"]

if s1 not in li:
    a=False
else:
    a=True
if s2 not in li:
    b=False
else:
    b=True

if a==b==True:
    print("AMBIGUOUS")
elif a==b==False:
    print("NA")
elif a==True:
    print("MMYY")
else:
    print("YYMM")
S = input()
s1 = S[0] + S[1]
s2 = S[2] + S[3]

if "00" < s1 < "13" and "00" < s2 < "13" :
    print("AMBIGUOUS")
elif "00" < s2 < "13" :
    print("YYMM")
elif "00" < s1 < "13" :
    print("MMYY")
else :
    print("NA")
s = (input())
a= s[0:2]
b= s[2:4]
a = int(a)
b= int(b)
if a == 0 or b == 0:
  if b!= 0 and b<13:
    print('YYMM')
  elif a!= 0 and a<13:
    print('MMYY')
  else:
    print('NA')
elif a<13 or b<13:
  if a>12:
    print('YYMM')
  elif b>12:
    print('MMYY')
  else:
    print('AMBIGUOUS')
else:
  print('NA')
def main():
    S = input().rstrip()
    v1 = int(S[:2])
    v2 = int(S[2:])
    if 1 <= v1 <= 12 and 1 <= v2 <= 12:
        print("AMBIGUOUS")
    elif 1 <= v1 <= 12 and (v2 >= 13 or v2 == 0):
        print("MMYY")
    elif (v1 >= 13 or v1 == 0) and 1 <= v2 <= 12:
        print("YYMM")
    else:
        print("NA")


if __name__ == '__main__':
    main()
s=int(input())
a=s//100
b=s%100
if 1<=a<=12 and 1<=b<=12:
    print("AMBIGUOUS")
elif 1<=a<=12 and not 1<=b<=12:
    print("MMYY")
elif 1<=b<=12 and not 1<=a<=12:
    print("YYMM")
else:
    print("NA")
s=input()
ym=True if 0 < int(s[2:]) < 13 else False
my=True if 0 < int(s[:2]) < 13 else False
if my and ym:
  print('AMBIGUOUS')
elif my:
  print('MMYY')
elif ym:
  print('YYMM')
else:
  print('NA')
def is_month(t):
    return 1 <= int(t) <= 12

s = input()
pre, suf = s[:2], s[2:]

if is_month(pre) and is_month(suf):
    print('AMBIGUOUS')
elif not is_month(pre) and not is_month(suf):
    print('NA')
elif is_month(pre) and not is_month(suf):
    print('MMYY')
else:
    print('YYMM')
# 126 B

s = input()

fir = int(s[:2])
sec = int(s[2:])

if fir > 0 or sec > 0:
    if 1 <= fir <= 12 and 1 <= sec <= 12 :
        print("AMBIGUOUS")
    elif 1 <= fir <= 12: 
        print("MMYY")
    elif 1 <= sec <= 12:
        print("YYMM") 
    else:
        print("NA")
else:
    print("NA")
x = input()
a, b = int(x[0:2]), int(x[2:4])
flag = 0
ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"]

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0):
    flag = 3
elif ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)):
    flag = 2
elif ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)):
    flag = 1


print(ans[flag])
s=str(input())
a=s[:2]
b=s[-2:]
m=['01','02','03','04','05','06','07','08','09','10','11','12']
if a not in m and b in m:
  print('YYMM')
elif a in m and b not in m:
  print('MMYY')
elif a in m and b in m:
  print('AMBIGUOUS')
else:
  print('NA')
n = input()
a = int(n[0]+n[1])
b = int(n[2]+n[3])

if 1 <= a <= 12 and 1 <= b <=12:
  print("AMBIGUOUS")
elif 1 <= b <= 12:
  print("YYMM")
elif 1 <= a <= 12 :
  print("MMYY")
else:
  print("NA")
s = raw_input()
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(tuple([(0<int(s[2*i:2*i+2]) <= 12)	for i in range(2)]))))]
S = input()

f = int(S[:2])
b = int(S[2:])

if 1 <= f <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1 <= b <= 12:
    print('YYMM')
elif 1 <= f <= 12:
    print('MMYY')
else:
    print('NA')
S=input()
mae=int(S[:2])
ato=int(S[2:])

if (1<=mae<=12) and (1<=ato<=12):
  print('AMBIGUOUS')
elif (1<=mae<=12) and (not (1<=ato<=12)):
  print('MMYY')
elif (not (1<=mae<=12)) and (1<=ato<=12):
  print('YYMM')
else:
  print('NA')
s = input()
b = int(s[0:2])
a = int(s[2:])
if 0 < b < 13 and 0 < a < 13:
	print('AMBIGUOUS')
elif 0 < b < 13:
	print('MMYY')
elif 0 < a < 13:
  	print('YYMM')
else:
	print('NA')
S=input()
a=int(S[:2])#前半
b=int(S[2:4])
cYYMM=b>0 and b<13
cMMYY=a>0 and a<13
#print(a,b)
#print(["NO","YES"][1-cond])
print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
s = input()
a = 1 <= int(s[:2]) <= 12
b = 1 <= int(s[2:]) <= 12
if a and b:
    print("AMBIGUOUS")
elif a:
    print("MMYY")
elif b:
    print("YYMM")
else:
    print("NA")
S = input()
S_front = S[:2]
S_back = S[2:]

if 0 < int(S_front) < 13:
	if 0 < int(S_back) < 13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 0 < int(S_back) < 13:
		print("YYMM")
	else:
		print("NA")
s = input()

s_a = int(s[:2])
s_b = int(s[2:])

if s_a >= 1 and s_a <=12 and s_b >= 1 and s_b <=12:
  ans = "AMBIGUOUS"
elif (s_a > 12 or s_a == 0) and s_b >= 1 and s_b <=12:
  ans = "YYMM"
elif (s_b > 12 or s_b == 0) and s_a >= 1 and s_a <=12:
  ans = "MMYY"
else:
  ans = "NA"

print(ans)
s = input()

y = int(s[:2])
m = int(s[2:])
if 1 <= y <= 12 and 1 <= m <= 12:
    print("AMBIGUOUS")
elif 1 <= y <= 12:
    print("MMYY")
elif 1 <= m <= 12:
    print("YYMM")
else:
    print("NA")
def solve():
    S = input()
    l = int(S[:2])
    r = int(S[2:])
    
    if 1 <= l <= 12:
        if 1 <= r <= 12:
            return 'AMBIGUOUS'
        else:
            return 'MMYY'
    else:
        if 1 <= r <= 12:
            return 'YYMM'
        else:
            return 'NA'

print(solve())
s = input()
if int(s[:2]) >= 1 and int(s[:2]) <= 12 and int(s[2:]) >= 1 and int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif int(s[:2]) >= 1 and int(s[:2]) <= 12:
    print('MMYY')
elif int(s[2:]) >= 1 and int(s[2:]) <= 12:
    print('YYMM')
else:
    print('NA')
s = input()
a = 1<= int(s[:2]) <=12
b = 1<= int(s[2:]) <=12
if a and b:
    print("AMBIGUOUS")
elif a:
    print('MMYY')
elif b:
    print('YYMM')
else:
    print('NA')
S = input()

from datetime import datetime as dt

ans = 0

#x = dt.strptime(S, "%Y%m")

try:
  x = dt.strptime("20"+S, "%Y%m")
  ans_s = "YYMM"
except:
  ans += 1
try:
  dt.strptime(S[:2] + "20" + S[2:], "%m%Y")
  ans_s = "MMYY"
except:
  ans += 1
  
if ans == 2:
  print("NA")
elif ans == 0:
  print("AMBIGUOUS")
else:
  print(ans_s)
s = list(input())
s1 = ''.join(s[:2])
s2 = ''.join(s[2:])
flag1 = False
flag2 = False
if 1 <= int(s1) and int(s1) <= 12:
  flag1 = True
if 1 <= int(s2) and int(s2) <= 12:
  flag2 = True
if flag1 and flag2:
  print('AMBIGUOUS')
elif flag1:
  print('MMYY')
elif flag2:
  print('YYMM')
else:
  print('NA')
S = input()

heads = int(S[:2])
tails = int(S[2:])


def is_month(n):
    return n >= 1 and n <= 12


if is_month(heads) and (not is_month(tails)):
    print("MMYY")
elif (not is_month(heads)) and (not is_month(tails)):
    print("NA")
elif (not is_month(heads)) and is_month(tails):
    print("YYMM")
else:
    print("AMBIGUOUS")
s=int(input())
s1=s//100
s2=s-s1*100
if 0<s1<=12 and 0<s2<=12:
    print("AMBIGUOUS")
elif (s1>12 or s1==0) and 0<s2<=12:
    print("YYMM")
elif 0<s1<=12 and (s2>12 or s2==0):
    print("MMYY")
else:
    print("NA")
S=input()

if 1<=int(S[:2])<=12:
  if 1<=int(S[2:])<=12:
    print("AMBIGUOUS")
  elif 0<=int(S[2:])<=99:
    print("MMYY")
elif 0<=int(S[:2])<=99:
  if 1<=int(S[2:])<=12:
    print("YYMM")
  elif 0<=int(S[2:])<=99:
    print("NA")
S = input()
mm = ["0"+str(x) for x in range(1,10)]+["10","11","12"]
mmyy = (S[:2] in mm)
yymm = (S[2:] in mm)
a = "NA"

if yymm and mmyy:
  a = "AMBIGUOUS"
elif yymm:
  a = "YYMM"
elif mmyy:
  a = "MMYY"
  
print(a)
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    s1=s[:2]
    s2=s[2:]
    l=['01','02','03','04','05','06','07','08','09','10','11','12']
    if s1 in l and s2 in l:
        print('AMBIGUOUS')
    elif s1 in l and s2 not in l:
        print('MMYY')
    elif s1 not in l and s2 in l:
        print('YYMM')
    else:
        print('NA')
resolve()
s = input()

i1 = int(s[:2])
i2 = int(s[2:])



def f(i):
    if (0 < i < 13):
        return 1
    elif (0 < i < 100):
        return 2
    else:
        return 0


f1 = f(i1)
f2 = f(i2)

if (f1 == 1):
    if (f2 == 1):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if (f2 == 1):
        print("YYMM")
    else:
        print("NA")
n=input()

n1,n2=int(n[:2]),int(n[2:])
if (n1>12 and n2>12) or (n1==0 and n2==0):
    print("NA")
elif (n1!=0 and n1<=12) and (n2!=0 and n2<=12):
    print("AMBIGUOUS")
elif n1!=0 and n1<=12:
    print("MMYY")
elif n2!=0 and n2<=12:
    print("YYMM")
else:
    print("NA")
s=input()
s1=int(s[0:2])
s2=int(s[2:])

if (s1==0 or s1>12) and (s2==0 or s2>12):
    print("NA")
elif (s1>0 and s1<=12) and ((s2>0 and s2<=12)):
    print("AMBIGUOUS")
elif (s1>0 and s1<=12) and (s2==0 or s2>12):
    print("MMYY")
else:
    print("YYMM")
import sys
A=int(sys.stdin.readline(2))
D=int(sys.stdin.readline(2))
if A>=1 and A<=12:
	if D>=1 and D<=12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
elif D>=1 and D<=12:
	print("YYMM")
else:
	print("NA")
S = input()
left = int(S[:2])
right = int(S[2:])
year_flag = [0, 0]

if left > 12 or left == 0:
    year_flag[0] += 1
if right > 12 or right == 0:
    year_flag[1] += 1

if sum(year_flag) == 2:
    print('NA')
elif sum(year_flag) == 0:
    print('AMBIGUOUS')
elif year_flag[0] == 1:
    print('YYMM')
else:
    print('MMYY')
a=int(input())
x=a//100
y=a%100
c=False
d=False
if 1<= x<=12:
    c=True
if 1<= y<=12:
    d=True
if c==True and d==True:
    print("AMBIGUOUS")
if c==True and d==False:
    print("MMYY")
if c==False and d==True:
    print("YYMM")
if c==False and d==False:
    print("NA")
S = input()
s1 = int(S[:2])
s2 = int(S[2:])

if 1 <= s1 <= 12:
    if 1 <= s2 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= s2 <= 12:
        print("YYMM")
    else:
        print("NA")
def is_month(x):
  if 1 <= x <= 12:
    return True
  else:
    return False

S = input()
first, latter = is_month(int(S[:2])), is_month(int(S[2:]))
if first and latter:
  ans = "AMBIGUOUS"
elif not first and not latter:
  ans = "NA"
elif first:
  ans = "MMYY"
else:
  ans = "YYMM"
print(ans)
import sys
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし

S = LI2()

a = 10*S[0]+S[1]
b = 10*S[2]+S[3]

if 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif not 1 <= a <= 12:
    if 1 <= b <= 12:
        print('YYMM')
    else:
        print('NA')
else:
    print('MMYY')
def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13 and (front > 0 and latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA')
main()
s = input()
a = int(s[:2])
b = int(s[2:])

if 0<a<13:
    if 0<b<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<b<13:
        print("YYMM")
    else:
        print("NA")
def check_my(string):
    if 1 <= int(string) <= 12:
        return 'YorM'
    else:
        return 'Y'

s = input()
my_set = (check_my(s[0:2]), check_my(s[2:4]))
if my_set == ('YorM', 'YorM'):
    print('AMBIGUOUS')
elif my_set == ('YorM', 'Y'):
    print('MMYY')
elif my_set == ('Y', 'YorM'):
    print('YYMM')
else:
    print('NA')
n = int(input())
n1 = n//100
n2 = n%100
if 0<n1<13 and 0<n2<13: print("AMBIGUOUS")
elif 0<n1<13: print("MMYY")
elif 0<n2<13: print("YYMM")
else: print("NA")
s = int(input())
L = s//100
R =s%100

if 1 <= L <=12:
    if 1<= R <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<= R <=12:
        print('YYMM')
    else:
        print('NA')
def main():
    s = input()
    a=s[:2]
    b=s[2:]
    if (a=="00" or 12<int(a)<100) and (1<= int(b)<=12):
        print("YYMM")
    elif (1<= int(a)<=12) and (b=="00" or 12<int(b)<100):
        print("MMYY")
    elif ((1<= int(a)<=12) and (0<=int(b)<13) )or ((1<= int(b)<=12) and (0<=int(a)<13)):
        print("AMBIGUOUS")
    else:
        print("NA")
main()
S=input()
Sf=int(S[:2])
Sb=int(S[2:])
if 1<=Sf<=12:
  if 1<=Sb<=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1<=Sb<=12:
    print('YYMM')
  else:
    print('NA')
S = input()
months = [i for i in range(1, 13)]
left = int(S[:2])
right = int(S[2:])
if left in months and right in months:
    print('AMBIGUOUS')
elif left in months:
    print('MMYY')
elif right in months:
    print('YYMM')
else:
    print('NA')
data=input()
n=int(data[:2])
m=int(data[2:])
if 1<=n<=12:
    if 1<=m<=12:
        print("ambiguous".upper())
        exit()
    else:
        print("MMYY")
        exit()
if 1<=m<13:
    print("YYMM")
    exit()
print("NA")
def main():
    s=input()
    s1=int(s[:2])
    s2=int(s[2:])
    yymm = 1 <= s2 <= 12
    mmyy = 1 <= s1 <= 12
    if yymm and mmyy:
        print("AMBIGUOUS")
    elif yymm:
        print("YYMM")
    elif mmyy:
        print("MMYY")
    else:
        print("NA")

if __name__ == "__main__":
    main()
S = input()
if 0<int(S[0]+S[1])<13:	#MMかYY
  if 0<int(S[2]+S[3])<13:	#MMかYY
    print('AMBIGUOUS')
  else:	#YY
    print('MMYY')
else:	#YY
  if 0<int(S[2]+S[3])<13:	#MM
    print('YYMM')
  else:	#YY
    print('NA')
S = input()
left = int(S[:2])
right = int(S[2:])

if 0 < left <= 12:
    if 0 < right <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < right <= 12:
        print('YYMM')
    else:
        print('NA')
s = input()

fore = int(str(s[0]) + str(s[1]))
aft = int(str(s[2]) + str(s[3]))

if 1 <= fore <= 12:
    if 1 <= aft <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

elif 1 <= aft <= 12:
    print('YYMM')
else:
    print('NA')
n=input()

n1,n2=int(n[:2]),int(n[2:])
#if (n1>12 and n2>12) or (n1==0 and n2==0):
#   print("NA")
if (n1!=0 and n1<=12) and (n2!=0 and n2<=12):
    print("AMBIGUOUS")
elif n1!=0 and n1<=12:
    print("MMYY")
elif n2!=0 and n2<=12:
    print("YYMM")
else:
    print("NA")
def is_month( n :int ):
  return ( 1 <= n ) and ( n <= 12 )

def judge( first, second ):
  if (first and second):
    return "AMBIGUOUS"
  elif (first and not(second)):
    return "MMYY"
  elif (not( first ) and second):
    return "YYMM"
  else:
    return "NA"

s = input()
first = is_month( int( s[0:2] ))
second = is_month( int( s[2:4] ))
print( judge( first, second ) )
S=input()

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

if(1<=a<=12 and 1<=b<=12):
  print("AMBIGUOUS")
elif(1<=a<=12):
  print("MMYY")
elif(1<=b<=12):
  print("YYMM")
else:
  print("NA")
S = input()
f, l = S[:2], S[2:]

if 1 <= int(f) <= 12 and 1 <= int(l) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(f) <= 12:
    print('MMYY')
elif 1 <= int(l) <= 12:
    print('YYMM')
else:
    print('NA')
#!/usr/bin/env python3

s = str(input())

a = s[0:2]

b = s[2:]


def div(a):
    a = int(a)
    if a <= 12 and a >= 1:
        return "BOTH"
    else:
        return "YY"


if div(a) == div(b):
    if div(a) == "YY":
        print("NA")
    else:
        print("AMBIGUOUS")
elif div(a) == "YY":
    print("YYMM")
else:
    print("MMYY")
S= input()

f=int(S[0]+S[1])
r=int(S[2]+S[3])

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

if a <= 12 and b <= 12:
    if a==0 and b!=0:
        print("YYMM")
    elif b==0 and a!=0:
        print("MMYY")
    elif a==0 and b==0:
        print("NA")
    else:
        print("AMBIGUOUS")
elif a<=12 and b>12:
    if a==0:
        print("NA")
    else:
        print("MMYY")
elif a>12 and b<=12:
    if b==0:
        print("NA")
    else:
        print("YYMM")
else:
    print("NA")
s=input()
m=int(s[:2])
n=int(s[2:])
flag1=1<=m and m<=12
flag2=1<=n and n<=12
if flag1 and flag2 : print("AMBIGUOUS")
elif flag1 : print("MMYY")
elif flag2 : print("YYMM")
else : print("NA")
s=input()
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif 1<=b<=12:
  print('YYMM')
elif 1<=a<=12:
  print('MMYY')
else:
  print('NA')
s=input()

if 12<int(s[:2]) or 0==int(s[:2]):
    if 12>=int(s[2:])>=1:
        print("YYMM")
    else:
        print("NA")
elif 1<=int(s[:2])<=12:
    if 12>=int(s[2:])>=1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
S=input()
x=int(S[:2])
y=int(S[2:])

if 0<x<13 and 0<y<13:print("AMBIGUOUS")
elif 0<x<13:print("MMYY")
elif 0<y<13:print("YYMM")
else:print("NA")
S = input()
f = int(S[:2])
s = int(S[2:])
if 1 <= f <= 12:
  if 1 <= s <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif 1 <= s <= 12:
  print('YYMM')
else:
  print('NA')
def f(s):

	return tuple([(0<int(s[2*i:2*i+2]) <= 12)	for i in range(2)])
		
print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(f(raw_input()))))]
s = input()
a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
  print('AMBIGUOUS')
elif 0 <= a <= 99 and 1 <= b <= 12:
  print('YYMM')
elif 0 <= b <= 99 and 1 <= a <= 12:
  print('MMYY')
else:
  print('NA')