peterverebics/CodeNet_Python_118 huggingface dataset:
s = input()

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

if s1 == 0 or s2 ==0:
  print("NA")
  
elif s1>12 and s2>12:
  print("NA")

elif s1>12 and s2<=12:
  print("YYMM")

elif s1<=12 and s2>12:
  print("MMYY")
  
else:
  print("AMBIGUOUS")
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 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 = list(map(str, input()))

F = int(S[0]+S[1])
L = int(S[2]+S[3])

if L == 0 or F == 0 or F >= 13 and L >= 13:
  print('NA')

elif F <= 12 and L > 12:
  print('MMYY')
  
elif L <= 12 and F > 12:
  print('YYMM')
  
 
else:
  print('AMBIGOUS')
n=input()
f=n[:2]
l=n[2:]
if (f=="00" and l=="00") or (int(f)>12 and int(l)>12):
    print("NA")
elif int(f)>12 or f=="00":
    print("YYMM")
elif int(l)>12 or l=="00":
    print("MMYY")
else:
    print("AMBIGUOUS")
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()
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 (a=="00" or 12<int(b)<100):
        print("MMYY")
    elif (1<= int(a)<=12) and (a=="00" or 0<int(b)<100) or (1<= int(b)<=12) and (a=="00" or 0<int(a)<100):
        print("AMBIGUOUS")
    else:
        print("NA")
main()
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")
elif s[2:] in num:
    print("YYMM")
else:
    print("NA")
try:
    s1=(input(''))
    if len(s1)==4:
        check=list((s1))
    assert bool(int(check[0]+check[1])<=12) != bool(int(check[2]+check[3])<=12)
    if int(check[0]+check[1])<=12:
        print("MMYY")
    elif int(check[2]+check[3])<=12:
        print("YYMM")
except AssertionError:
    if int(check[0]+check[1])<=12 and int(check[2]+check[3])<=12:
        print("AMBIGUOS")
    else:
        print("NA")
n=int(input())
a2=n%100
a1=n//100
if 0<a1 and a1<=12:
	print("YYMM")
	
elif 0<a2 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 = 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 a in (4,6,9,11) and 1<=b<=30 or a in (1,3,5,7,8,10,12) and 1<=b<31 or a==2 and 1<=b<=29:
  print('MMYY')
elif b in (4,6,9,11) and 1<=a<=30 or b in (1,3,5,7,8,10,12) and 1<=a<31 or b==2 and 1<=a<=29:
  print('YYMM')
else:
  print('NA')
S = input()

ans = "NA"
if int(S[:2]) <= 12 and int(S[2:]) <= 12:
  ans = "AMBIGUOUS"
elif 1 <= int(S[:2]) <= 12 and int(S[2:]) > 12:
  ans = "MMYY"
elif int(S[:2]) > 12 and 1 <= int(S[2:]) <= 12:  
  ans = "YYMM"

print(ans)
S = input()
ju1, ju2 = S[:2],S[2:]

if (int(ju1) > 0 and int(ju1) <= 12) or (int(ju2) > 0 and int(ju2) <= 12):
    if (int(ju1) > 0 and int(ju1) <= 12) and (int(ju2) > 0 and int(ju2) <= 12):
        print('AMBIGUOUS')
    elif (int(ju1) > 0 and int(ju1) <= 12) and int(ju2) > 0:
        print('MMYY')
    elif int(ju1) > 0 and (int(ju2) > 0 and int(ju2) <= 12):
        print('YYMM')
else:
    print('NA')
S = input()
if (int(S[:2])>12 or int(S[:2])==0) and (int(S[2:])>12 or int(S[2:])==0):
    print('NA')
elif (int(S[:2])<=12 and int(S[:2])!=0) and (int(S[2:])>12 and int(S[2:])==0):
    print('MMYY')
elif (int(S[2:])<=12 and int(S[2:])!=0) and (int(S[:2])>12 and int(S[:2])==0):
    print('YYMM')
else:
    print('AMBIGUOUS')
S = str(input())
year = S[0] + S[1]
month = S[2] + S[3]
if int(year) > 12 and int(month) != 0:
    print('YYMM')
elif int(month) > 12 and int(month) != 0:
    print('MMYY')
elif int(year) <= 12 and int(month) <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
s = input()
n1 = int(s[0:2])
n2 = int(s[2:4])

flag1 = False
flag2 = False
if n1 >= 1 and n2 >= 1 and n2 <= 12:
    flag1 = True
if n1 >= 1 and n1 <= 12 and n2 >= 1:
    flag2 = True

if flag1 and flag2:
    print('AMBIGUOUS')
elif flag1:
    print('YYMM')
elif flag2:
    print('MMYY')
else:
    print('NA')
NN = input()
AA = int(NN[0:2])
BB = int(NN[2:-1])
count1 = 0
count2 = 0
if AA >12 or AA == 00:
  count1 +=1
if BB >12 or BB == 00:
  count2 +=2
if count1 == 0 and count2 == 0:
  print('AMBIGUOUS')
elif count1 ==1 and count2 == 0:
  print('YYMM')
elif count1 ==0 and count2 == 1:
  print('MMYY')
else:
  print('NA')
yymm = input()
if int(yymm[2:4]) == 0:
    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')
S = str(input())
year = S[0] + S[1]
month = S[2] + S[3]
if (int(year) > 12 and int(month) >12) or (int(year) == 0) or (int(month) == 0):
    print('NA')
elif int(year) > 12:
    print('YYMM')
elif int(month) >12:
    print('MMYY')
elif int(year) <= 12 and int(month) <= 12:
    print('AMBIGUOUS')
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')
S = list(input())
f1 = 1
f2 = 1
A = int(''.join(S[:2]))
B = int(''.join(S[2:]))
if A >= 13 or A == 0:
    f1 = 0
if B >= 13 or A == 0:
    f2 = 0
if f1 == 1 and f2 == 1:
    print('AMBIGUOUS')
elif f1 == 1 and f2 == 0:
    print('MMYY')
elif f1 == 0 and f2 == 1:
    print('YYMM')
else:
    print('NA')
def resolve():
    S = input()
    P = int(S[0]+S[1])
    Q = int(S[2]+S[3])
    if 0<P<=12 and 0<Q<=12:
        print("AMBIGUOUS")
    elif 0<P<=12 and (Q>12 or Q==0):
        print("MMYY")
    elif (P>13 or P==0) and 0<Q<=12:
        print("YYMM")
    else:
        print("NA")
resolve()
s=input()
a=int(s[:2])
b=int(s[2:])

if a==0 & b==0:
    print('NA')


if a==0:
    if b<13:
        print('YYMM')
    elif b>0:
        print('NA')
if b==0:
    if a<13:
        print('MMYY')
    elif a>0:
        print('NA')

if a>12:
    if b>12:
        print('NA')
    elif b>0:
        print('YYMM')
elif a>0:
    if b>12:
        print('MMYY')
    elif b>0:
        print('AMBIGUOUS')
s = input()
a = int(s[:2])
b = int(s[2:])
if 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
elif a<=99 and 0<b<=12:
    print('YYMM')
elif 0<b<=12 and a<=99:
    print('MMYY')
else:
    print('NA')
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=int(input())
a=s//100
b=s%100
if (a==0 or a>12) and (b==0 or b>12):
    print("Na")
elif (a==0 or a>12):
    print("YYMM")
elif (b==0 or b>12):
    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 s_f>12 and s_b<=12:
    print('YYMM')
elif s_f>12 and s_b>12:
    print("NA")
elif s_f<=12 and s_b<=12:
    print("AMBIGUOUS")
else:
    print('MMYY')
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 s_f<=12 and s_b<=12:
    print("AMBIGUOUS")
elif s_f<=12 and s_b>12:
    print('MMYY')
elif s_f>12 and s_b<=12:
    print('YYMM')
elif s_f>12 and s_b>12:
    print('NA')
S = int(input())

a = int(S/100 - (S%100)/100)
b = int(S%100)

if( 0<a<13 and 0<b<13 ):
  print("AMBIGUOUS")
if( 0<a<13 and 12<b<100 ):
  print("MMYY")
if( 12<a<100 and 0<b<13 ):
  print("YYMM")
if( 12<a<100 and 12<b<100 ):
  print("NA")
if( a==0 and 12<b<100 ):
  print("NA")
if( 12<a<100 and b==0 ):
  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 and b > 12 else "YYMM" if a > 12 else "MMYY" if b > 12 else "AMBIGUOUS")
s=input()
if 1<=int(s[:2])<=12 and 13<=int(s[2:4])<=31:print("MMYY")
elif 12<int(s[:2])<=31 and 1<=int(s[2:4])<=12:print("YYMM")
elif 1<=int(s[:2])<=12 and 1<=int(s[2:4])<=12:print("AMBIGUOUS")
else :print("NA")
s = input()
a, b = int(s[:2]), int(s[2:])
if a <= 12 and b <= 12:
    print('AMBIGUOUS')
elif (a > 12 and b > 12) or (a == 0 and b > 12) or (a > 12 and b == 0) :
    print('NA')
elif a > 12:
    print('YYMM')
else:
    print('MMYY')
S = input()
 
s1 = int(S[0] + S[1])
s2 = int(S[2] + S[3])
 
if s1 > 12: #YY
    if 0 < s2 <= 12:
        print('YYMM')
    else:
        print('NA')
elif s2 > 12: #YY
    if 0 < s1 <= 12:
        print('MMYY')
    else:
        print('NA')
S = str(input())

S1 = S[0:2]
S2 = S[2:4]

if 1 <= int(S1) <= 12:
    if 1 <= int(S2) <= 12:
        print('AMBIGOUS')
        exit()
    else:
        print('MMYY')
        exit()

if 1 <= int(S2) <= 12:
    if 1 <= int(S1) <= 12:
        print('AMBIGOUS')
        exit()
    else:
        print('YYMM')
        exit()

print('NA')
s = input()
a = int(s[:2])
b = int(s[2:])
if 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
elif a<=99 and 0<b<=12:
    print('YYMM')
elif 0<b<=12 and 0<a<=99:
    print('MMYY')
else:
    print('NA')
s=list(str(input()))

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

if s1==00 or s1>12 and s2==00 or s2>12:
            print('NA')

elif s1==00 or  s1>12 and 1<=s2<=12:
            print('YYMM')
elif s2==00 or s2>12 and 1<=s1<=12 :
            print('MMYY')
else:
            print('AMBIGUOUS')
s = input()

if '00' in s:
    print('NA')
elif int(s[:2]) <= 12 and int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif int(s[2:]) < 13:
    print('YYMM')
elif int(s[:2]) < 13:
    print('MMYY')
else:
    print('NA')
n=input()
a=int(n[0:2])
b=int(n[2:4])
if a<=12 and b<=12:
    print('AMBIGUOUS')
elif a>=12 and a<=12:
    print('MMYY')
elif 12<=b and b<=12:
    print('YYMM')
else:
    print('NA')
s = input()
front, back = map(int, [s[:2], s[2:]])

yymm = False
mmyy = False
if 1 <= front and front <= 12:
  mmyy = True
  if 1 <= back and back <= 12:
    yymm = True
else:
  if 1 <= back and back <= 12:
    mmyy = True
  else:
    pass
    

if yymm and mmyy:
  print('AMBIGUOUS')
elif yymm:
  print('YYMM')
elif mmyy:
  print('MMYY')
else:
  print('NA')
s = input()
if int(s[:2]) and int(s[2:]) > 12:
  print("NA")
elif int(s[:2]) and int(s[2:]) == 0:
  print("NA")
elif int(s[:2]) > 12 and int(s[2:]) == 0:
  print("NA")
elif int(s[:2]) == 0 and int(s[2:]) > 12:
  print("NA")
elif int(s[:2]) > 12:
  print("YYMM")
elif int(s[2:]) > 12:
  print("MMYY")
else:
  print("AMBIGUOUS")
s = input()

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

if int(s[:2]) >= 13 and int(s[2:]) >= 13:
  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()
am = s[0]+s[1]
pm = s[2]+s[3]
p = ["01","02","03","04","05","06","07","08","09","10","11","12"]
if am in p and pm in p:
    print("AMBIGUOUGS")
elif am in p and pm not in p:
    print("MMYY")
elif am not in p and pm in p:
    print("YYMM")
elif am not in p and pm not in p:
    print("NA")
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])
if a == 00 and b > 12:
    print("NA")
elif a > 12 and b == 00:
    print("NA")
elif a <= 12 and b <= 12:
    print("AMBIGUOUS")
elif a <= 12:
    print("MMYY")
elif b <= 12:
    print("YYMM")
else:
    print("NA")
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")
if((up >= 13 and down >= 13) or (up == 0 or down == 0)):
    print("NA")
s = input()

former = int(s[:2])
later = int(s[2:])

if former==0 or later==0:
  print("NA")
elif former<13 and later<13:
  print("AMBIGUOUS")
elif former<13:
  print("MMYY")
else:
  print("YYMM")
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 and 1<=b<=12:
  print('YYMM')
elif b>12 and 1<=a<=12:
  print('MMYY')
else:
  print('NA')
s = input()
s1, s2 = s[:2],s[2:]
if s1>'12' and s2>'12':
    print('NA')
elif s1<='12' and s2<='12':
    if s1 == '00':
        print('YYMM')
    if s2 == '00':
        print('MMYY')
    else :
        print('AMBIGUOUS')
elif s1<='12' and s2>'12':
    print('NA' if s1 == '00' else 'MMYY')   
elif s2<='12' and s1>'12':
    print('NA' if s2 == '00' else 'YYMM')
else:
    print('NA')
import sys
S = str(input())

if (S[0]+S[1]) == "00" or (S[2]+S[3]) == "00":
  print("NA")
  sys.exit()

if int(S[0]+S[1]) > 12:
  if int(S[2]+S[3]) <= 12:
    print("YYMM")
  else:
    print("NA")
if int(S[0]+S[1]) <= 12:
  if int(S[2]+S[3]) <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
s = input()
print("{} {}".format(s[0:2],s[2:4]))
s1 = int(s[0:2])
s2 = int(s[2:4])

s1m = False
s1y = False
s2m = False
s2y = False
if s1 <= 12 and s1 >= 1:
  s1y = True
  s1m = True
elif s1 > 12 or s1 == 0:
  s1y = True
  
if s2 <= 12 and s2 >= 1:
  s2y = True
  s2m = True
elif s2 > 12  or s2 == 0:
  s2y = True

if s1y and s2y and s1m and s2m:
  print("AMBIGUOUS")
elif s1y and s2m :
  print("YYMM")
elif s2y and s1m :
  print("MMYY")
else :
  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) or (f <= 0 and s <= 0):
    print("NA")  
elif (f > 12 and 0 < s <= 12) or (f <= 0 and 0 < s <= 12):
    print("YYMM")
elif (0 < f <= 12 and s > 12) or (0 < f <= 12 and s <= 0):
    print("MMYY")
elif 0 < f <= 12 and 0 < s <= 12:
    print("AMBIGUOUS")
s = input()

upper = int(s[:2])
lower = int(s[2:4])

if upper > 12:
    if lower > 31 or lower <= 0: print('NA')
    else: print('YYMM')
else:
    if upper <= 0: print('NA')
    elif lower > 31: print('MMYY')
    else: print('AMBIGUOUS')
s = input()
s1 = int(s[0])
s2 = int(s[1])
s3 = int(s[2])
s4 = int(s[3])
if(0 < (10 * s1 + s2) < 12 and 0 < (10 * s3 + s4) < 12):
  print('AMBIGUOUS')
elif(0 < (10 * s3 + s4) < 12):
  print('YYMM')
elif(0 < (10 * s1 + s2) < 12):
  print('MMYY')
else:
  print('NA')
NN = input()
AA = int(NN[0:2])
BB = int(NN[2:-1])
count1 = 0
count2 = 0
if AA >12:
  count1 +=1
if BB >12:
  count2 +=2
if count1 == 0 and count2 == 0:
  print('AMBIGUOUS')
elif count1 ==1 and count2 == 0:
  print('YYMM')
elif count1 ==0 and count2 == 1:
  print('MMYY')
else:
  print('NA')
S = input()
L = int(S[:2])
R = int(S[2:])
if (1<=L<=12):
    if (1<=R<=12):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if (1<=R<=12):
        print("YYMM")
    else:
        print("NO")
s = input()

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

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

if 0 < a <= 12:
    if 0 < b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < b <= 12:
        print("YYMM")
    else:
        print("NA")
s=str(input())
a,b=int(s[:2]),int(s[2:])
if (a>12 and b>12) or min(a,b)==0 :
  print("NA")
elif a>12 and b<12:
  print("YYMM")
elif a<12 and b>12:
  print("MMYY")
else:
  print("AMBIGUOUS")
s = input()
s = [int(s[:2]),int(s[2:])]

l = ['', '']
for i in range(2):
    if (s[i] == 0):
        print('NA')
        break
    elif (1 <= s[i] <= 12):
        l[i] = 'MM'
    else:
        l[i] = 'YY'
else:
    if (l.count('MM') == 2):
        print('AMBIGUOUS')
    else:
        print(l[0]+l[1])
yymm = input()

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

else:
    print("NA")
s = input()
s1 = s[:2]
s2 = s[2:]
if int(s1) > 12 and int(s2) > 12 or (s1 == '00' and s2 == '00'):
  print('NA')
elif (int(s1) > 12) or (s1 == '00'):
  print('YYMM')
elif (int(s2) > 12) or (s2 == '00'):
  print('MMYY')
elif int(s1) <= 12 and int(s2) <= 12 and int(s1) > 0 and int(s2) > 0:
  print('AMBIGUOUS')
else:
  print('NA')
s = input()
if s == '0000' or (int(s[:2]) >= 13 and int(s[-2:]) >= 13):
    print('NA')
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')
a= int(input())
x= int(a%100)
y= int(a//100)
if x>0 and y>0:
  if x<13 and y<13:
    print("AMBIGUOUS")
  elif x<13 and y<100:
    print("MMYY")
  elif x<100 and y<13:
    print("YYMM")
  else:
    print("NA")
else:
  print("NA")
S=input()
S1=int(S[:2])
S2=int(S[2:])

if ((0<=S1 and S1<=99) and (1<=S2 and S2<=12)):
    if (0<=S1 and S1<=12) and (1<=S2 and S2<=99):
        print("AMBIGUOUS")
    else:
        print("YYMM")
elif (1<=S1 and S1<=12) and (0<=S2 and S2<=99):
    print("MMYY")

else:
    print("NA")
N = list(input())
if 1 <= int(N[0]+N[1]) <=12 and 1 <= int(N[2]+N[3]) <= 12:
  print('AMBIGUOUS')
elif 1 <= int(N[0]+N[1]) <=12 and 12<int(N[2]+N[3])<1:
  print('MMYY')
elif 12<int(N[0]+N[1])<1 and 1 <= int(N[2]+N[3]) <=12:
  print('YYMM')
else:
  print('NA')
S = input()
 
if int(S[:2]) >= 13 or int(S[:2]) == 0:
  if int(S[2:]) >= 13 or int(S[2:]) == 0: print('NA')
  else: print('YYMM')
else:
  if int(S[2:]) >= 13: print('MMYY')
  else: print('AMBIGUOUS')
S = input()
f,e = int(S[:2]),int(S[2:])
if f>12:
  if 0<e<=12:
    print('YYMM')
  else:
    print('NA')
elif 0<f<12:
  if e>12:
    print('MMYY')
  else:
    print('AMBIGUOUS')
else:
  print('NA')
s = list(input())
head = int(s[0] + s[1])
tail = int(s[2] + s[3])
 
if 0 < tail < 13:
    print('YYMM')
elif 0 < head < 13:
    print('MMYY')
elif (0 < head < 13) and (0 < tail < 13):
    print('AMBIGUOUS')
else:
    print('NA')
a=input()
b=int(a[0]+a[1])
c=int(a[2]+a[3])
if b>12 or b==0:
  if c>12 or c==0:
    print("Na")
  elif 1<=c<=12:
    print("YYMM")
if c>12 or c==0:
  if b>12 or b==0:
    print("Na")
  elif 1<=b<=12:
    print("MMYY")
else:
  print("AMBIGUOUS")
S = input()
a = int(S[:2])
b = int(S[2:])

ym = False
my = False
if a > 0 and b>0 and b <= 12:
  ym = True
if b > 0 and a>0 and a <= 12:
  my = True

if ym and my:
  print("AMBIGUOUS")
elif ym and not(my):
  print('YYMM')
elif not(ym) and ym:
  print('MMYY')
else:
  print('NA')
S = input()

if(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 = 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 and 1<=b<=12:
  print('YYMM')
elif b>12 and 1<=a<=12:
  print('MMYY')
elif a>12 and b>12:
  print('NA')
elif a<0 and b<0:
  print('NA')
ym = int(input())
 
ym1 = int(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])

if s1 > 12: #YY
    if 0 < s2 <= 12:
        print('YYMM')
    else:
        print('NA')
    exit()
elif s2 > 12: #YY
    if 0 < s1 <= 12:
        print('MMYY')
    else:
        print('NA')
    exit()
else:
    if s1 == 0 and s1 == 0:
        print('NA')
    else:
        print('AMBIGUOUS')
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()

ym = True
my = True

tmp = ''
for i in range(2):
    tmp += s[i]
tmp = int(tmp)
if tmp<1:
    ym = False
    my = False
elif 12 < tmp:
    my = False

tmp = ''
for i in range(2):
    tmp += s[i+2]
tmp = int(tmp)
if tmp < 1:
    ym = False
    my = False
if 12 < tmp:
    ym = False

if ym and my:
    print('AMBIGUOUS')
elif ym and not my:
    print('YYMM')
elif not ym and my:
    print('MMYY')
else:
    print('NA')
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")
s = list(input())
s = [int(i+j) for (i,j) in zip(s[::2],s[1::2])]

if 1 <= s[0] <= 12:
  if 1 <= s[1] <= 12:
    print("AMIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= s[1] <= 12:
    print("YYMM")
  else:
    print("NA")
s=input()
be=s[:2]
af=s[2:]

if s=="0000":
  print("NA")

elif int(be)<=12 and int(af)<=12 and be!="00" and af!="00":
  print("AMBIGUOUS")

elif int(af)<=12:
  if af=="00" and int(be)<=12:
    print("MMYY")
  else:
    print("YYMM")
    
elif int(be)<=12:
  if be=="00":
    print("NA")
  else:
    print("MMYY")
  
else:
  print("NA")
s = int(input())
a, b = s // 100, s % 100

if 1<=a<=12 and 1<=a<=12:
    print('AMBIGUOUS')
elif 1<=a<=12:
    print('MMYY')
elif 1<=b<=12:
    print('YYMM')
else:
    print('NA')
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=int(input())
a=s//100
b=s%100
if a>12 and b>12:
    print("Na")
elif a>12:
    print("YYMM")
elif b>12:
    print("MMYY")
else:
    print("AMBIGUOUS")
import sys

S = input()

if int(S[:2]) == 0 and 0 < int(S[2:]) <= 12:
  print("YYMM")
  sys.exit()

if int(S[:2]) == 0 or int(S[2:]) == 0 or (int(S[:2]) > 12 and int(S[2:]) > 12):
  print("NA")
elif int(S[:2]) > 12 and int(S[2:]) <= 12:
  print("YYMM")
elif int(S[:2]) <= 12 and int(S[2:]) > 12:
  print("MMYY")
else:
  print("AMBIGUOUS")
text=input()
a=int(text)
f=a/100
f=int(f)
l=int(text[2:])
s=0
if( f >0 and f<=12 and l>12):
    print('MMYY')
if (l>0 and l<=12 and f>12):
    print('YYMM')
if( ( f >0 and f<=12 and l>=0) or (l>0 and l<=12 and f>=0)):
    print('AMBIGUOUS')
else:
    print('NA')
s=input()
be=s[:2]
af=s[2:]

if int(be)>=13 and int(af)<=12:
  if af=="00":
    print("NA")
  else:
    print("YYMM")
elif int(be)<=12 and int(af)>=13:
  if be=="00":
    print("NA")
  else:
    print("MMYY")
elif int(be)<=12 and int(af)<=12:
  print("AMBIGUOUS")
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 s2 == 0:
    print("NA")
elif s1 > 12 and s2 <= 12:
    print("YYMM")
elif s1 <= 12 and s2 > 12:
    print("MMYY")
else:
    print("AMBIGUOUS")
n=int(input())
a2=n%100
a1=n//100
if 0<a2 and a1>12:
	print("YYMM")
	
elif 0<a1 and a2>12:
	print("MMYY")
elif 0<a1 and a1<=12 and a2<=12 and a2>0:
			print("AMBIGUOUS")
	
		

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