peterverebics/CodeNet_Python_118 huggingface dataset:
n=input()

n1,n2=int(n[:2]),int(n[2:])
if (n1>12 and n2>12) or n1==0 or 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("errer")
s = str (input())
bflag = True
lflag = True
if not(s[0] + s[1] in ['01','02','03','04','05','06','07','08','09','10','11','12']):
    bflag = False
if not(s[2] + s[3] in ['01','02','03','04','05','06','07','08','09','10','11','12']):
    lflag = False
if bflag:
    if lflag:
        print('ANBIGUOUS')
    else:
        print('MMYY')
else:
    if lflag:
        print('YYMM')
    else:
        print('NA')
s = input()
a = int(s[:2])
b = int(s[2:])
if a <= 12:
  if b <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if b <= 12:
    print('YYMM')
  else:
    print('NA')
S = input()
YY = int(S[0:2])
MM = int(S[2: ])

if YY <= 12 and MM <= 12 and MM > 0:
  print("AMBIGUOUS")
elif YY <= 12 and YY > 0 and MM >= 13:
  print("MMYY")
elif YY >= 13 and MM <= 12 and MM > 0:
  print("YYMM")
else:
  print("NA")
S = list(input())

S = list(map(int, S))

if S[0] == S[1] == 0 or S[2] == S[3] == 0 or (S[0] > 2 and S[2] > 0):
    print("NA")
elif S[2] > 1 or (S[2] == 1 and S[3] > 2):
    print("MMYY")
elif S[0] > 1 or (S[0] == 1 and S[1] > 2):
    print("YYMM")
else:
    print("AMBIGUOUS")
s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
if s1 == s2 == 0:
    print('NA')
elif s1 <= 12 and s2 <= 12 and s1 >= 1 and s2 >= 1:
    print('AMBIGUOUS')
elif s1 <= 12 and s1 >= 0:
    print('MMYY')
elif s2 <= 12 and s2 >= 0:
    print('YYMM')
else:
    print('NA')
S = input()


if 0 < int(S[:2]) <= 12 and  0 < int(S[2:]) <= 12:
    print("AMBIGUOUS")
elif (int(S[:2]) > 12 or int(S[:2]) == 0) and 0 < int(S[2:]) <= 12:
    print("YYMM")
elif 0 < int(S[:2]) <= 12 and (int(S[2:]) > 12 or int(S[:2]) == 0):
    print("MMYY")
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:
        print("MMYY")
    elif v1 >= 13 and 1 <= v2 <= 12:
        print("YYMM")
    else:
        print("NA")


if __name__ == '__main__':
    main()
s = input()
head = int(s[:2])
teil = int(s[2:])
if head>12 or head == 0:
  if teil>12 or teil == 0:
    print("NA")
  else:
    print("YYMM")
else:
  if teil>12:
    print("MMYY")
  else:
    print("AMBIGUOUS")
s = list(input())

for i in range(4):
    s[i] = int(s[i])

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

if a == 0 or b == 0:
    print("NA")
elif a >= 13 and b >= 13:
    print("NA")
elif a >= 13 and b <= 12:
    print("YYMM")
elif a <= 12 and b >= 13:
    print("MMYY")
else:
    print("AMBIGUOUS")
s = input()
s_f = int(s[0]+s[1])
s_b = int(s[2]+s[3])

#print(s_f)
#print(s_b)
if s_f==0 or s_b==0:
    print('NA')
elif 0<s_f<=12 and 0<s_b<=12:
    print("AMBIGUOUS")
elif 0<s_f<=12 and s_b>12:
    print('MMYY')
elif s_f>12 and 0<s_b<=12:
    print('YYMM')
elif s_f>12 and s_b>12:
    print('NA')
s=input()
f=int(s[:2])
b=int(s[2:4])

if (b>=13 or b==0)and f>=13 :
    print('NA')
elif (b>=13 or b==0)and f<=12 :
    print('MMYY')
elif b<=12 and f>=13 :
    print('YYMM')
else:
    print('AMBIGUOUS')
def 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 b==0 or 13<=b<=99:
    print("MMYY")
  elif 1<=b<=12 and a==0 or 13<=a<=99:
    print("YYMM")
  else:
    print("NA")
main()
S = input()
up = int(S[0:2])
down = int(S[2:4])

if(up >= 13 and 0 < down < 13):
    print("YYMM")
if(0 < up < 13 and down >= 13):
    print("MMYY")
if(0 < up < 13 and 0 < down < 13):
    print("AMBIGUOUS")
else:
    print("NA")
s = list(input())

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

if a > 12 and 1 <= b <= 12:
    print("YYMM")
elif 1 <= a <= 12 and b > 12: 
    print("MMDD")
elif 1 <= a <= 12 and 1 <= b <= 12:
        print("AMBIGUOUS")
else:
    print("NA")
s = input()
first = int(s[:2])
second =int(s[2:])

if (first > 0 and first < 13) and (second > 0 and second < 13):
    print("AMBIGUOUS")
elif (first > 0 and first < 13) and (second > 12):
    print("MMYY")
elif (first > 12) and (second > 0 and second < 13):
    print('YYMM')
else:
    print('NA')
s=str(input())
a="Y"
b="Y"
if 0<int(s[0:2])<13:
    print("#")
    a="MY"
if 0<int(s[2:5])<13:
    b="MY"

if a==b=="Y":
    ans="NA"
elif a=="Y" and b=="MY":
    ans="YYMM"
elif a=="MY" and b=="Y":
    ans="MMYY"
else:
    ans="AMBIGUOUS"
print(ans)
S = input()

front = int(S[:2])
rear = int(S[2:])

if (front > 12 and rear > 12) or (front > 12 and rear == 0) or (rear > 12 and front == 0) or (front == 0 and rear == 0):
    print("NA")
    exit()
elif 0 < rear <= 12 and front > 12:
    print("YYMM")
    exit()
elif 0 < front <= 12 and rear > 12:
    print("MMYY")
elif 0 < front <= 12 and 0 < rear <= 12:
    print("AMBIGUOUS")
s = input()

if 1 <= int(s[0:3]) <= 12 and 1 <= int(s[2:5]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(s[0:3]) <= 12:
    print('MMYY')
elif 1 <= int(s[2:5]) <= 12:
    print('YYMM')
else:
    print('NA')
s = str(input())
num = ['01','02','03','04','05','06','07','08','09','10','11','12']
if s[:2] == '00' or s[2:] == '00':
    print("NA")
elif s[:2] in num and s[2:] in num:
    print("AMBIGUOUS")
elif s[:2] in num:
    print("MMYY")
else:
    print("YYMM")
S = input()

try:
    first = int(S[:2])
except ValueError:
    first = -1

try:
    end = int(S[2:])
except ValueError:
    end = -1

def judgeYM(num):
    if num >= 1 and num <= 12:
        return "M"
    elif num >= 0 and num <=99:
        return "Y"
    else:
        return "N"

fj = judgeYM(first)
ej = judgeYM(end)

if fj == "N" or ej == "N":
    print("NA")
elif fj == "M" and ej == "M":
    print("AMBIGUOUS")
elif fj == "M":
    print("MMYY")
else:
    print("YYMM")
s=input()
if s[:2]=='00' or s[2:]=='00':
  print('NA')
elif 0 < int(s[:2]) <= 12 and 0 < int(s[2:]) <= 12:
  print('AMBIGUOUS')
elif 0 < int(s[:2]) <= 12:
  print('MMYY')
elif 0 < int(s[2:]) <= 12:
  print('YYMM')
s=input()
a=int(s[:2])
b=int(s[2:])
if a>0 and a<13:
	if b>0 and b<13:
		print("AMBIGUOUS")
	elif b!=0:
		print("MMYY")
	else:
		print("NA")
elif a!=0:
	if b>0 and b<13:
		print("YYMM")
	else:
		print("NA")
else:
	print("NA")
s=str(input())

s1="".join(s[:2])
s1i=int(s1)
s2="".join(s[2:])
s2i=int(s2)

if s1i <=12 and s2i <=12:
    print("AMBIGUOUS")
elif s1i >12 and s2i >12:
    print("NA")
elif s1i == 0 or s2i ==0:
    print("NA")  
elif s1i >12 and s2i <= 12:
    print("YYMM")
elif s1i <= 12 and s2i > 12:
    print("MMYY")
S = input()
s1,s2 = int(S[0:2]),int(S[2:4])

def f(n):
  if n >= 1 and n <= 12:
    return True
  else:
    return False

if f(s1) and f(s2):
  print("AMBIGUOUS")
elif f(s1) and s2 > 12 or s2 ==0:
  print("MMYY")
elif f(s2) and s1 > 12 or s1 ==0:
  print("YYMM")
else:
  print("NA")
s = input()
j = int(s[:2])
k = int(s[2:])
if j <= 12 and k <= 12 and j != 0 and k != 0:
    print("AMBIGUOUS")
elif j > 12 and k != 0:
    print("YYMM")
elif j <= 12 and k > 12:
    print("MMYY")
else:
    print("NA")
s = input()
s1 = int(s[0:2])
s2 = int(s[2:4])
ans = [False, False]
if s1 != 0 and 1 <= s2 <= 12:
    ans[0] = True
if s2 != 0 and 1 <= s1 <= 12:
    ans[1] = True
if ans == [False, False]:
    print("NA")
elif ans == [True, True]:
    print("AMBIGUOUS")
elif ans == [True, False]:
    print("YYMM")
elif ans == [False, True]:
    print("MMYY")
S=str(input())

Ans=[int(S[0]+S[1]),int(S[2]+S[3])]

if Ans[0]==0 or Ans[1]==0:
    print("NA")
elif Ans[0]>12 or Ans[0]<1:
    if Ans[1]>12 or Ans[1]<1:
        print("NA")
    else:
        print("YYMM")
else:
    if Ans[1]>12 or Ans[1]<1:
        print("MMYY")
    else:
        print("AMBIGUOUS")
s = input()
ans = 'NA'
if 1 <= int(s[:2]) <= 12:
    ans = 'MMYY'
    if 1 <= int(s[2:]) <= 12:
        ans = 'ANBIGUOUS'
elif 1 <= int(s[2:]) <= 12:
    ans = 'YYMM'
print(ans)
S = input()
a = int(S[0]+S[1])
b = int(S[2]+S[3])
if a > 12 and b >12:
  print('NA')
if (a == 0 and b >12) or (b ==0 and a > 12):
  print('NA')
elif a <= 12 and b <= 12:
  print('AMBIGUOUS')
elif a <= 12 and b > 12:
  print('MMYY')
elif a > 12 and b <= 12:
  print('YYMM')
yymm = input()
if int(yymm[0:2]) == 0 and int(yymm[2:4]) >= 13:
    print('NA')
elif int(yymm[0:2]) <= 12 and int(yymm[2:4]) <= 12:
    print('AMBIGUOUS')
elif int(yymm[0:2]) <= 12 and int(yymm[2:4]) <= 99:
    print('MMYY')
elif int(yymm[0:2]) <= 99 and int(yymm[2:4]) <= 12:
    print('YYMM')
else:
    print('NA')
yymm = input()

if 1 <= int(yymm[0:2]) and int(yymm[0:2]) <= 12 or 1 <= int(yymm[2:4]) and int(yymm[2:4]) <= 12:
    print('AMBIGUOUS')
elif (1 <= int(yymm[0:2]) and int(yymm[0:2])) <= 12 and int(yymm[2:4]) <= 99:
    print('YYMM')
elif int(yymm[0:2]) <= 99 and 1 <= (int(yymm[2:4]) and int(yymm[2:4]) <= 12):
    print('MMYY')
else:
    print('NA')
x = int(input())
a = x // 1000117
b = x % 100

a_is_month = 0 < a & a <= 12
b_is_month = 0 < b & b <= 12

if a_is_month:
    if b_is_month:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b_is_month:
        print("YYMM")
    else:
        print("NA")
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    S = input()

    first = int(S[:2])
    second = int(S[2:])

    if first < 10 and second < 10:
        print('NA')
    elif first == 0 or second == 0:
        print('NA')
    elif first > 12 and second <= 12:
        print('YYMM')
    elif first <= 12 and second > 12:
        print('MMYY')
    else:
        print('AMBIGUOUS')


if __name__ == "__main__":
    main()
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 "YYMM"
  elif (not( first ) and second):
    return "MMYY"
  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()

l=[]
for i in range(len(s)):
    l.append(s[i])
l1=[]
l1.append(int(l[0]+l[1]))
l1.append(int(l[2]+l[3]))

if(l1[0] <= 0 or l1[1] <= 0) or (l1[0] > 12 and l1[0] > 12):
    print('NA')
elif l1[0] > 12 and l1[1] > 0 and  l1[1] <= 12:
    print('YYMM')
elif l1[0] > 0 and  l1[0] <= 12 and l1[1] > 12:
    print('MMYY')
elif (l1[0] > 0 and l1[0] <= 12) and (l1[1] > 0 and l1[1] <= 12):
    print('AMBIGUOUS')
S = input()
if 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()

if S[:2] == '00' and int(S[2:]) > 12:
    print('NA')
elif S[2:] == '00' and int(S[:2]) > 12:
    print('NA')
elif S == '0000':
    print('NA')
if S[:2] == '00' and int(S[2:]) <= 12:
    print('YYMM')
elif S[2:] == '00' and int(S[:2]) <= 12:
    print('MMYY')
elif int(S[:2]) <= 12 and int(S[2:]) <= 12:
    print('AMBIGUOUS')
elif int(S[:2]) <= 12:
    print('MMYY')
elif int(S[2:]) <= 12:
    print('YYMM')
else:
    print('NA')
s = input()
be = s[0:2]
af = s[2:4]
if int(be) <= 12 and int(af) <= 12:
  print('AMBIGUOUS')
elif (int(be) > 12 and af == '00') or (be == '00' and int(af) > 12):
  print('NA')
else:
  if int(be) > 12:
    print('MMYY')
  elif int(af) > 12:
    print('YYMM')
s = input()
upper_input = int(s[:2])
lower_input = int(s[2:])

if upper_input >= 0 and upper_input<= 12:
  if lower_input >= 0 and lower_input <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if lower_input >= 0 and lower_input <= 12:
    print('YYMM')
  else:
    print('NA')
s=input()

l=[]
for i in range(len(s)):
    l.append(s[i])
l1=[]
l1.append(int(l[0]+l[1]))
l1.append(int(l[2]+l[3]))

if l1[0] <= 0 or l1[1] <= 0:
    print('NA')
elif l1[0] > 12 and l1[1] > 0 and  l1[1] <= 12:
    print('YYMM')
elif l1[0] > 0 and  l1[0] <= 12 and l1[1] > 12:
    print('MMYY')
elif (l1[0] > 0 and l1[0] <= 12) and (l1[1] > 0 and l1[1] <= 12):
    print('AMBIGUOUS')
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:
    print("YYMM")
elif 1<=a<=12 and 12<b:
    print("MMYY")
elif 1<=a<=12 and 1<=b<=12: 
    print("AMBIGUOUS")
else:
    print("NA")
S = input()
if (int(S[:2]) == 0 and (int(S[2:]) >= 13 or int(S[:2]) == 0)) or \
   (int(S[2:]) == 0 and (int(S[:2]) >= 13 or int(S[:2]) == 0)) or \
   (int(S[2:]) >= 13 and int(S[:2]) >= 13):
    print('NA')
elif (int(S[:2]) >= 13 and int(S[2:]) < 13) or \
     (int(S[:2]) == 0 and int(S[2:]) < 13):
    print('YYMM')
elif (int(S[2:]) >= 13 and int(S[:2]) < 13) or \
     (int(S[2:]) == 0 and int(S[:2]) < 13):
    print('MMYY')
else:
    print('AMBIGUOUS')
ym = int(input())

ym1 = ym/100
ym2 = ym%100

if ym1>=1 and ym1<=12 and ym2>=1 and ym2<=12:
  print('AMBIGUOUS')
elif ym1<1 or ym1 >12 and ym2<1 or ym2>12:
  print('NA')
elif ym2<1 or ym2>12:
  print('MMYY')
else:
  print('YYMM')
s=input()
s1=int(s[0]+s[1])
s2=int(s[2]+s[3])
ans=""
if s1>12:
	if s2>12 or s2==0:
		ans="NA"
	else:
		ans="YYMM"
elif s1==0:
		ans="NA"
else:
	if s2>12:
		ans="MMYY"
	else:
		ans="AMBIGUOUS"

print(ans)
s=input()
f1=int(s[:2])<=12
f2=int(s[2:4])<=12
if f1 and f2:print("AMBIGUOUS")
elif not f1 and not f2:print("NA")
elif f1:print("MMYY")
else:print("YYMM")
s=input()
s1=int(s[0]+s[1])
s2=int(s[2]+s[3])
if (0<s1<13)&(0<s2<13):
    print("AMBIGUOUS")
elif (0<s1<13)&(12<s2<100):
    print("MMYY")
elif (12<s1<100)&(0<s2<13):
    print("YYMM")
elif (s1==0)|(s2==0):
    print("NA")
else:
    print("NA")
s = input()
x = int(s[:2])
y = int(s[2:])
if 0<x<=12 and 0<y<=12:
  print('AMBIGUOUS')
elif 0<x<=12:
  print('MMYY')
elif 0<=y<=12:
  print('YYMM')
else:
  print('NA')
N = int(input())

if 199 <= N <= 1299:
    if 9901 <= N <= 9912:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 9901 <= N <= 9912:
    print("YYMM")
else:
    print("NA")
S=list(input())
def main():
    while True:
        if int(S[0]+S[1])>12:
            if int(S[2]+S[3])==0:
                return 'NA'
            if int(S[2]+S[3])>12:
                return 'YYMM'
            else:
                return 'AMBIGUOUS'
        else:
            return 'MMYY'
            
print(main())
s=input()

s1=s[0]+s[1]
s2=s[2]+s[3]

if s1=='00' or s2=='00':
  print('NA')
  exit()

if s1[0]=='0' or s1=='11' or s1=='12':
  ans1='MM'
else:
  ans1='YY'

if s2[0]=='0' or s2=='11' or s2=='12':
  ans2='MM'
else:
  ans2='YY'

if ans1==ans2=='MM':
  print('AMBIGUOUS')
else:
  print(ans1+ans2)
s = int(input())
s_1 = s // 100 #4桁の数字列の上2桁を取り出す
s_2 = s % 100  #4桁の数字列の下2桁を取り出す

if 1 <= s_1 <=12 and 1 <= s_2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s_1 <= 12 and s_2 > 12 or s_2 == 0:
    print("MMYY")
elif 1 <= s_2 <= 12 and s_1 > 12 or s_1 == 0:
    print("YYMM")
else:
    print("NA")
S = list(input())

fo = int(''.join(S[:2]))
la = int(''.join(S[2:]))

if fo==0 or la==0:
  print("NA")
elif fo <= 12 and la <= 12:
  print("AMBIGUOUS")
elif fo <= 12 and la > 12:
  print("MMYY")
elif fo > 12 and la <= 12:
  print("YYMM")
elif fo > 12 and la > 13:
  print("NA")
s = input()

if s[:2] == "00" or s[2:] == "00":
  print("NA")
  exit()

if 1 <= int(s[:2]) <= 12 and 1 <= int(s[2:]) <= 12:
  print("AMBIGUOUS")
  exit()

if int(s[2:]) > 13:
  print("MMYY")
else:
  print("YYMM")
S = input()
S1 = int(S[:2])
S2 = int(S[2:])

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

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

if a <= 12:
  if b <= 12 and b != 0:
    print("AMBIGUOUS")
  elif b > 12 or b == 0:
    print("MMYY")
else:
  if b > 12 or b == 0:
    print("NA")
  elif b <= 12:
    print("YYMM")
S = input()
S_a = int(S[0] + S[1])
S_b = int(S[2] + S[3])
if((S_a >= 1 and S_a <= 12) and (S_b < 1 or S_b > 12)):
  print('MMYY')
elif((S_a < 1 or S_a > 12) and (S_b >= 1 and S_b <= 12)):
  print('YYMM')
elif((S_a >= 1 and S_a <= 12) and (S_b >= 1 and S_b <= 12)):
  print('AMBIGUOUS')
else:
  print('NO')
s = input()
a = int(s[0:2])
b = int(s[2:])
if 1 <= a:
    if 13 <= a:
        if 1 <= b and b <= 12:
            print('YYMM')
        else:
            print('NA')
    else:
        if b == 0:
            print('NA')
        elif b <= 12:
            print('AMBIGUOUS')
        else:
            print('MMYY')
else:
    print('NA')
A = 15
B = 200

if A >= 13:
  price = B
elif 6 <= A <= 12:
  price = B/2
else:
  price = 0

print(price)
#ABC126 B

S = list(map(int,input()))
if 1 <= S[0]*10 + S[1] <= 12 and 1 <= S[2]*10 + S[3] <= 12:
    print("AMBIGUOUS")
elif 1 <= S[0]*10 + S[1] <= 12 and S[2]*10 + S[3] > 12:
    print("MMYY")
elif S[0]*10 + S[1] > 12 and  1 <= S[2]*10 + S[3] <= 12:
    print("YYMM")
elif S[0]*10 + S[1] > 12 and S[2]*10 + S[3] > 12:
    print("NA")
import sys
input = lambda: sys.stdin.readline().rstrip()

S = input()

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

if (f <= 0 and s > 12) or (f > 12 and s <= 0):
    print("NA")  
elif (f > 12 and s <= 12) or (f <= 0 and s <= 12):
    print("YYMM")
elif f <= 12 and s > 12 or (f <= 12 and s <= 0):
    print("MMYY")
elif f <= 12 and s <= 12:
    print("AMBIGUOUS")
#import sys
#import math
#import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
N=input()

a=int(N[0:2])
b=int(N[2:4])

if (a==0 or b==0):
  print('NA')
elif (a<13 and b<13):
  print("AMBIGUOUS")
elif (a<13):
  print('MMYY')
elif b<13:
  print('YYMM')
else:
  print('NA')
s = [int(k) for k in list(input())]
s1 = 10*int(s[0])+int(s[1])
s2 = 10*int(s[2])+int(s[3])
if s1 == 0 or s2 == 0:
    print("NA")
elif s1 <= 12 and s2 <= 12:
    print("AMBIGUOUS")
elif s1 <= 12 and s2 >= 12:
    print("MMYY") 
else:
    print("YYMM")
def main():
    S = input()
    if 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
        return "AMBIGUOUS"
    elif (int(S[:2]) > 12 or int(S[:2]) == 0) and 12 >= int(S[2:]) > 0:
        return "YYMM"
    elif 0 < int(S[:2]) <= 12 and (12 < int(S[2:]) or int(S[2:]) == 0):
        return "MMYY"
    else:
        return "NA"


if __name__ == '__main__':
    main()
S = input()
if int(S[0]+S[1]) <= 12 and int(S[2]+S[3]) <= 12:
    print('AMBIGUOUS')

elif 0 < int(S[0]+S[1]) and int(S[0]+S[1]) <= 12 and int(S[2]+S[3]) >12:
    print('MMYY')

elif int(S[0]+S[1]) > 12 and 0 < int(S[2]+S[3]) and int(S[2]+S[3]) <= 12:
    print('YYMM')

else:
    print('NA')
s = input()
i = int(s[:2])
j = int(s[2:])
if 1 <= i and i <= 12:
    if 1 <= j and j <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= i:
        if 1 <= j and j <= 12:
            print('YYMM')
        else:
            print('NA')
    else:
        print('NA')
n=int(input())
n_1=n//100
n_2=n%100

if  1<=n_1<=12 and 13<=n_1<=31:
            print('MMYY')
elif 1<=n_1<=12 and 1<=n_2<=12:
            print('AMBIGUOUS')
elif 13<=n_1<=31 and 1<=n_2<=12:
            print('YYMM')
else:
            print('NA')
def main():
    s = input()
    #print(s[:2], s[2:4])
    if int(s[:2]) > 12 and (int(s[2:4]) >= 1 and int(s[2:4]) <= 12) :
        print("YYMM")
    elif int(s[2:4])>12 and (int(s[:2]) >=1 and int(s[:2]) <=12) :
        print("MMYY")
    elif (int(s[:2]) >= 1 and int(s[:2])) <= 12 and (int(s[2:4]) >=1 and int(s[2:4]) <= 12) :
        print("AMBIGUOUS")
    else:
        print("NA")

if __name__ == "__main__":
    main()
S = int(input())
a = S % 100
b = (S- (S % 100))/100
if   b <= 12 and  a<=12 and a!=0 and b!= 0:
       print("AMBIGUOUS")
elif b <= 12 and a!=0 :
       print("MMYY")
elif a<=12 and a!=0  :
       print("YYMM")
else :
      print("NA")
S = list(input())

a = int("".join(S[0:2]))
b = int("".join(S[2:4]))

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12 and b != 0:
    print("MMYY")
elif 1 <= b <= 12 and a != 0:
    print("YYMM")
else:
    print("NA")
s = input()

if int(s[:2])<=12 and int(s[2:])<=12:
  print('AMBIGUOUS')
elif int(s[:2])<=12 and int(s[2:])>12:
  print('MMYY')
elif int(s[:2])>12 and int(s[2:])<=12:
  print('YYMM')
else:
  print('NA')
s=list(input())
a=int("".join(s[0:2]))
b=int("".join(s[2:4]))
print("NA" if a==0 or b==0 else 
      "NA" if a >= 13 and b >= 13 else 
      "YYMM" if a > 12 else 
      "MMYY" if b > 12 else 
      "AMBIGUOUS")
S = input()
if int(S[:2]) > 12 and int(S[2:]) > 12 or int(S[:2]) == 0 or int(S[2:]) == 0:
    print("NA")
elif int(S[:2]) > 12:
    print("YYMM")
elif int(S[2:]) > 12:
    print("MMYY")
else:
    print("AMBIGUOUS")
S = input()
ls = list(S)
lsa = [ls[0],ls[1]]
lsb = [ls[2],ls[3]]

a = int(''.join(lsa))
b = int(''.join(lsb))

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
  print('AMBIGIOUS')
elif (a >= 1 and a <= 12) and (b >= 13 or b == 0):
  print('MMYY')
elif (a >= 13 or a == 0) and (b >= 1 and b <= 12):
  print('YYMM')
else:
  print('NA')
n=int(input())
a2=n%100
a1=n//100
if 0<a2 and a2<=12 and a1>12:
	print("YYMM")
	
elif 0<a1 and a1<=12 and a2>12:
	print("MMYY")
elif 0<a1 and a1<=12 and a2<=12 and a2>0:
			print("AMBIGUOUS")
	
		

else:
	print("NA")
s = input()

a = s[0]+s[1]
b = s[2]+s[3]

a = int(a)
b = int(b)

if a == 0 or b == 0:
  print('NA')
  exit()

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

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

if a >12 and b>12 or a > 31 or b > 31 or a==0 or b == 0:
  print('NA')
elif 1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif 1<=a<=12 and 1<=b<=31:
  print('MMYY')
elif 1<=b<=12 and 1<=a<=31:
  print('YYMM')
else:
  print('NA')
S=str(input())

Ans=[int(S[0]+S[1]),int(S[2]+S[3])]

if Ans[0]==0 or Ans[1]==0:
    print("NA")
elif Ans[0]>12 or Ans[0]<1:
    if Ans[1]>12 or Ans[1]<1:
        print("NA")
    else:
        print("YYMM")
else:
    if Ans[1]>12 or Ans[1]<1:
        print("MMYY")
    else:
        print("AMBIGOUS")
n = input()
a = int(n[0:2])
b = int(n[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
	print('AMBIGUOUS')
elif 1 <= a <= 12 and b > 12:
	print('MMYY')
elif 1 <= b <= 12 and a > 12:
	print('YYMM')
else:
	print('NA')
S = str(input())
year = S[0] + S[1]
month = S[2] + S[3]
if int(year) <= 12 and int(month) <= 12:
    print('AMBIGUOUS')
elif int(year) > 0 and int(month) != 0:
    print('YYMM')
elif int(month) > 0 and int(year) != 0:
    print('MMYY')
else:
    print('NA')
s=input()
f=int(s[:2])
b=int(s[2:4])

if (f>=13 or f==00)and b>=13 :
    print('NA')
if (f>=13 or f==00)and 1<=b<=12 :
    print('YYMM')
elif 1<=f<=12 and (b>=13 or b==00) :
    print('MMYY')
elif f<=13 and (b>=13 or b==00) :
    print('AMBIGUOUS')
s=input()
f=int(s[:2])
b=int(s[2:])
if f<13 and b<13:
    print('AMBIGUOUS')
elif 0<b<13:
    print('YYMM')
elif f<13:
    print('MMYY')
else:
    print('NA')
c = input()
c = [int(c[0] + c[1]),int(c[2] + c[3])]
g = ""
if c[0] > 12 and c[1] < 13 and c[1] != 0:
    g = "YYMM"
if c[0] < 13 and c[1] > 12 and c[0] != 0:
    g = "MMYY"
if c[0] < 13 and c[1] < 13:
    g = "AMBIGUOUS"
if c[0] < 1 or c[1] < 1 or c[1] > 12 and c[0] > 12:
    g = "NA"
print(g)
S = input()

first_two = int(S[:2])
last_two = int(S[-2:])

if first_two == 0 or first_two > 12:
    if last_two == 0:
        print('NA')
    elif last_two <= 12:
        print('YYMM')
    else:
        print('NA')
elif first_two <= 12:
    if last_two == 0:
        print('NA')
    elif last_two <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
s=list(input())
s=list(map(int,s))

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

if (a==0 and b==0) or (a>=13 and b>=13):
  print("NA")
elif 0<a<=12 or 0<a<=12:
  print("AMBIGUOUS")
elif 0<a<12:
  print("MMYY")
else:
  print("YYMM")