peterverebics/CodeNet_Python_118 huggingface dataset:
S = input()
Month = []
for i in range(1,13):
    if i < 10:
        Month.append("0" + str(i))
    else:
        Month.append(str(i))
YYMMpt = 0
MMYYpt = 0
if S[0:2] in Month:
    MMYYpt += 1
if S[2:4] in Month:
    YYMMpt += 1
if YYMMpt == 0 and MMYYpt == 0:
    print("NA")
elif YYMMpt == 0 and MMYYpt == 1:
    print("MMYY")
elif YYMMpt == 1 and MMYYpt == 0:
    print("YYMM")
else:
    print("AMBIGUOUS")
s = input()
if 1<=int(s[0:2])<=12 and 1<=int(s[2:4])<=12:
    print("AMBIGUOUS")
elif 1<=int(s[0:2])<=12:
    print("MMYY")
elif 1<=int(s[2:4])<=12:
    print("YYMM")
else:
    print("NA")
s = input()
x, y = int(s[:2]), int(s[2:])

if (1 <= x <= 12) & (1 <= y <= 12):
    print('AMBIGUOUS')
elif 1 <= x <= 12:
    print('MMYY')
elif 1 <= y <= 12:
    print('YYMM')
else:
    print('NA')
s=str(input())
a,b=int(s[:2]),int(s[2:])
f,g= 1<=a and a<=12, 1<=b and b<=12
if f and g:
  print("AMBIGUOUS")
elif f:
  print("MMYY")
elif g:
  print("YYMM")
else:
  print("NA")
S = input()
f = int(S[:2])
s = int(S[2:])

if 1 <= f <= 12 and 1 <= s <= 12:
    print("AMBIGUOUS")
elif 1 <= f <= 12:
    print("MMYY")
elif 1 <= s <= 12:
    print("YYMM")
else:
    print("NA")
s =input()
r =int(s[0:2])
l =int(s[2:4])

if 0 <r <13:
    if 0 <l <13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0 <l <13:
    if 0 <r <13:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    print('NA')
s=int(input())
s1=s/100
s2=s%100
if((1<=s1<=12)and(1<=s2<=12)):
    print('AMBIGUOUS')
elif(((s1<1) or (12<s1)) and(1<=s2<=12)):
    print('YYMM')
elif(((s2<1) or (12<s2)) and(1<=s1<=12)):
    print('MMYY')
else:
    print('NA')
S = input()
YY = int(S[0:2])
MM = int(S[2: ])

if YY <= 12 and YY > 0 and MM <= 12 and MM > 0:
  print("AMBIGUOUS")
elif YY <= 12 and YY > 0 and (MM >= 13 or MM == 0):
  print("MMYY")
elif (YY == 0 or YY >= 13) and MM <= 12 and MM > 0:
  print("YYMM")
else:
  print("NA")
#126 b
def change(x):
    if 1<=x<=12:
        return 0
    else:
        return 1
ans=["AMBIGUOUS","NA","MMYY","YYMM"]#[00,11,01,10]
s=input()
a=change(int(s[:2]))
b=change(int(s[2:]))
if a==b:
    print(ans[a])
else:
    print(ans[a+2])
s = input()

a = s[:2]
b = s[-2:]

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

if a in mm and b in mm:
    print("AMBIGUOUS")
elif a in mm:
    print("MMYY")
elif b in mm:
    print("YYMM")
else:
    print("NA")
S = input()
f = int(S[:2])
l = int(S[2:])
if f==0 or f>12:
  if l==0 or l>12:
    print("NA")
  else:
    print("YYMM")
else:
  if l==0 or l>12:
    print("MMYY")
  else:
    print("AMBIGUOUS")
S = list(map(int, input()))

if 0<S[0]*10+S[1]<=12 and 0<S[2]*10+S[3]<=12:
    print('AMBIGUOUS')
elif 0<S[0]*10+S[1]<=12:
    print('MMYY')
elif 0<S[2]*10+S[3]<=12:
    print('YYMM')
else:
    print('NA')
S = input()
first = int(S[:2])
second = int(S[2:])
if 1<=first<=12 and 1<=second<=12:
  print('AMBIGUOUS')
elif 1<=first<=12:
  print('MMYY')
elif 1<=second<=12:
  print('YYMM')
else:
  print('NA')
y = str(input())
ans = ["NA","MMYY","YYMM","AMBIGUOUS"]
k = 0
if 1 <= int(y[:2]) <= 12:
  k += 1
if 1 <= int(y[2:]) <= 12:
  k += 2
print(ans[k])
S = input()
L, R =  map(int, [S[:2], S[2:]])
 
if 1 <= L <= 12 and 1 <= R <= 12:
  print("AMBIGUOUS")
elif 1 <= L <= 12 and (R == 0 or R > 12):
  print("MMYY")
elif (L == 0 or L > 12) and 1 <= R <= 12:
  print("YYMM")
else:
  print("NA")
S=input()
left=int(S[:2])
right=int(S[2:])
mmyy,yymm=False,False
if 12>=left and left>=1:
    mmyy=True
if 12>=right and right>=1:
    yymm=True

if mmyy==True and yymm==False:
    print('MMYY')
elif mmyy==False and yymm==True:
    print('YYMM')
elif mmyy==True and yymm==True:
    print('AMBIGUOUS')
else:
    print('NA')
z = input()
x = int(z[:2])
y = int(z[2:])

if (0<x <= 12):
      if (0<y<= 12):
            print("AMBIGUOUS")
      else:
            print("MMYY")
elif (0<y <= 12):
      if (0<x<= 12):
            print("AMBIGUOUS")
      else:
            print("YYMM")
else:
      print("NA")
S = input()
s1 = int(S[:2])
s2 = int(S[2:])
def is_MM(s):
    return 1 <= s <= 12

if is_MM(s1) and is_MM(s2):
    print('AMBIGUOUS')
elif is_MM(s1):
    print('MMYY')
elif is_MM(s2):
    print('YYMM')
else:
    print('NA')
s = input()
l = s[:2]
r = s[2:]

if(int(l) >= 1 and int(l) <=12 and int(r) <= 12 and int(r) >= 1):
    print('AMBIGUOUS')
else :
    if(int(l) <= 12 and int(l) >= 1):
        print('MMYY')
    else:
        if(int(r) <= 12 and int(r) >= 1):
            print('YYMM')
        else:
            print('NA')
s = input()
head = int(s[:2])
tail = int(s[2:])

is_mmyy = False
is_yymm = False

if 1 <= head <= 12:
    is_mmyy = True

if 1 <= tail <= 12:
    is_yymm = True

if is_yymm and is_mmyy:
    print('AMBIGUOUS')
elif is_yymm:
    print('YYMM')
elif is_mmyy:
    print('MMYY')
else:
    print('NA')
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 = list(input())
if int(s[0])*10 + int(s[1]) > 12 or int(s[0]) + int(s[1]) == 0:
    if int(s[2])*10 + int(s[3]) <= 12 and int(s[2]) + int(s[3]) != 0:
        print("YYMM")
    else:
        print("NA")

else:
    if int(s[2])*10 + int(s[3]) > 12 or int(s[2]) + int(s[3]) == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")
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): 
    print("MMYY")
elif (second > 0 and second < 13):
    print('YYMM')
else:
    print('NA')
S=input()
a=int(S[:2])
b=int(S[2:])
ans=0
lab=["NA","MMYY","YYMM","AMBIGUOUS"]

if a>=1 and a<=12:
    ans+=1
    
if b>=1 and b<=12:
    ans+=2
    
print(lab[ans])
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"
print(x + y if x != y else "NA" if x == "YY" else "AMBIGUOUS")
S = input()

former = int(S[:2])
latter = int(S[2:])

if((former >= 13 or former == 0) and 1 <= latter <= 12):
    print("YYMM")
if((latter >= 13 or latter == 0) and 1 <= former <= 12):
    print("MMYY")
if(1 <= former <= 12 and 1 <= latter <= 12):
    print("AMBIGUOUS")
if((former >= 13 or former == 0) and (latter >= 13 or latter == 0)):
    print("NA")
s = input()
a = list(map(str, range(1, 10)))
b = list(map(str, range(0, 3)))
mm = 0
ba = 0
for i in [0, 2]:
    if s[i] == "0" and s[i+1] in a:
        mm += 1
        ba = i
    elif s[i] == "1" and s[i+1] in b:
        mm += 1
        ba = i
if mm == 0:
    print("NA")
elif mm == 1 and ba == 0:
    print("MMYY")
elif mm == 1 and ba == 2:
    print("YYMM")
elif mm == 2:
    print("AMBIGUOUS")
import sys
input=sys.stdin.readline

s=input()


if 0<int(s[:2])<13:
	upper=True
else:
	upper=False

if 0<int(s[2:])<13:
	low=True
else:
	low=False

if upper and low:
	print("AMBIGUOUS")

elif not upper and low:
	print("YYMM")

elif upper and not low:
	print("MMYY")
else:
	print("NA")
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()
a=int(s[0: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')
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = input()[:-1].decode()
    l = int(s[:2])
    r = int(s[2:])
    if (l >= 13 or l == 0) and 1 <= r <= 12:
        print('YYMM')
    elif 1 <= l <= 12 and (r >= 13 or r == 0):
        print('MMYY')
    elif 1 <= l <= 12 and 1 <= r <= 12:
        print('AMBIGUOUS')
    else:
        print('NA')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
S=input()
F=int(S[:2])
L=int(S[2:])

if 0<F<=12:
    if 0<L<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0<L<=12:
    print('YYMM')
else:
    print('NA')
s=list(input())
s1="".join(s[:2])
s2="".join(s[2:])
if 0<int(s1)<=12 and 0<int(s2)<=12:
    print("AMBIGUOUS")
elif 0<int(s1)<=12 and (int(s2)>12 or int(s2)==0):
    print("MMYY")
elif 0<int(s2)<=12 and (int(s1)>12 or int(s1)==0):
    print("YYMM")
else:
    print("NA")
s=int(input())
a=s//100
b=s-a*100
if a<13 and b<13 and a>0 and b>0:
    print("AMBIGUOUS")
elif a<13 and a>0:
    print("MMYY")
elif b<13 and b>0:
    print("YYMM")
else:
    print("NA")
def check_month(n):
  return 1 <= n <= 12
def check_year(n):
  return 0 <= n <= 99

S = input()
Y = int(S[:2])
M = int(S[2:])
if check_month(Y) and check_month(M):
  print('AMBIGUOUS')
elif check_month(Y) and check_year(M):
  print('MMYY')
elif check_year(Y) and check_month(M):
  print('YYMM')
else:
  print('NA')
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) or (a==0 and b ==0):
  print('NA')
elif a == 0:
  print('YYMM')
elif b == 0:
  print('MMYY')
elif  a <= 12 and b <= 12:
  print('AMBIGUOUS')
elif a <= 12 and b > 12:
  print('MMYY')
elif a > 12 and b <= 12:
  print('YYMM')
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
#print(s1, s2)
L=[]

for i in range(1, 13):
    L.append(i)


if s1 not in L and s2 not in L:
    print('NA')
elif s1 in L and s2 not in L:
    print('MMYY')
elif s1 not in L and s2 in L:
    print('YYMM')
else:
    print('AMBIGUOUS')
s = str(input())
a = int(s[0]) * 10 + int(s[1])
b = int(s[2]) * 10 + int(s[3])
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()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if 1<=s1<=12 and 0<=s2<=99:
    if 1<=s2<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<=s1<=99 and 1<=s2<=12:
        print("YYMM")
    else:
        print("NA")
S = str(input())

f, r = map(int, (S[:2], S[2:]))
ans = ''
if 1 <= f <= 12 and 1 <= r <= 12:
  ans = 'AMBIGUOUS'
elif 1 <= f <= 12:
  ans = 'MMYY'
elif 1 <= r <= 12:
  ans = 'YYMM'
else:
  ans = 'NA'

print(ans)
S = input()
l, r = map(int, [S[:-2], S[2:]])

if 0 < l < 13:
    if 0 < r < 13:
        print('AMBIGUOUS')
        exit()
    else:
        print('MMYY')
else:
    if 0 < r < 13:
        print('YYMM')
    else:
        print('NA')
s = int(input())
L, R = divmod(s, 100)
if 0 < L < 13:
    if 0 < R < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0 < R < 13:
    print('YYMM')
else:
    print('NA')
s = int(input())
s1 = s // 100
s2 = s % 100
c = 0
l = ["NA","YYMM","MMYY","AMBIGUOUS"]
if 1<=s2<=12:
  c += 1
if 1<=s1<=12:
  c += 2
print(l[c])
import datetime

s = input()
ans = [['NA', 'MMYY'], ['YYMM', 'AMBIGUOUS']]

try:
    datetime.datetime.strptime(s,"%y%m")
    ans1 = 1
except ValueError:
    ans1 = 0

try:
    datetime.datetime.strptime(s,"%m%y")
    ans2 = 1
except ValueError:
    ans2 = 0

print(ans[ans1][ans2])
S = input()
AA = int(S[:2]) 
BB = int(S[2:])
if (1 <= AA <= 12) and (1 <= BB <= 12):
    print('AMBIGUOUS')
elif (13 <= AA or AA == 0) and (1 <= BB <= 12):
    print('YYMM')
elif (1 <= AA <= 12) and (13 <= BB or BB == 0):
    print('MMYY')
else:
    print('NA')
s = list(input())
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

mae = a*10 + b 
ushiro = c*10 + d
if mae <= 12 and mae != 0:
    if ushiro <= 12 and ushiro != 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if ushiro <= 12 and ushiro != 0:
        print("YYMM")
    else:
        print("NA")
s = list(input())
a = int(s[0] + s[1])
b = int(s[2] + s[3])

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

def is_yymm(s):
    if 1<=int(s)<=12:
        return "both"
    else:
        return "YY"

left = is_yymm(S[:2])
right = is_yymm(S[2:])

ans = left + right

if ans=="YYboth":
    print("YYMM")
elif ans=="bothYY":
    print("MMYY")
elif ans=="bothboth":
    print("AMBIGUOUS")
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 <= a <= 12):
  print("MMYY")
elif (1 <= b <= 12):
    print("YYMM")
else:
  print("NA")
import math


def main():
    # n = int(input())
    # n, k = map(int, input().split())
    # h = list(map(int, input().split()))
    s = input()
    # h = [int(input()) for _ in rane(n)]
    f = int(s[:2])
    b = int(s[2:])
    if 1 <= f and f <= 12 and 1 <= b and b <= 12:
        print("AMBIGUOUS")
    elif 0 <= f and f <= 99 and 1 <= b and b <= 12:
        print("YYMM")
    elif 0 <= b and b <= 99 and 1 <= f and f <= 12:
        print("MMYY")
    else:
        print("NA")


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

first = int(S[0:2])
last = int(S[2:4])

if (0 < first < 13):
	if (0 < last < 13):
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if (0 < last < 13):
		print("YYMM")
	else:
		print("NA")
s = input()

s_1 = int(s[0:2])
s_2 = int(s[2:4])

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

l = int(s[0:2])
r = int(s[2:4])

if (l == 00 and r == 00) or (l>12 and r > 12) or (l == 00 and r > 12) or(l > 12 and r == 00):
    print("NA")
elif l > 12 and r < 13:
    print("YYMM")
elif l < 13 and r > 12:
    print("MMYY")
elif l == 00 and r < 13:
    print("YYMM")
elif l < 13 and r == 00:
    print("MMYY")
elif l <= 12 and r <= 12:
    print("AMBIGUOUS")
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
m = range(1,13)
if s1 in m and s2 in m:
    print('AMBIGUOUS')
elif s1 in m:
    print('MMYY')
elif s2 in m:
    print('YYMM')
else:
    print('NA')
S = input()
if int(S[:2]) != 0 and int(S[:2]) <= 12:
  if int(S[2:]) != 0 and int(S[2:]) <= 12: print("AMBIGUOUS")
  else:print("MMYY")
else:
  if int(S[2:]) != 0 and int(S[2:]) <= 12: print("YYMM")
  else:print("NA")
s=input()
f=int(s[:2])
b=int(s[2:])

if f>=1 and f<=12:
    if b>=1 and b<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

else:
    if b>=1 and b<=12:
        print('YYMM')
    else:
        print('NA')
s=input()
a=int(s[:2])
b=int(s[2:])
if (a > 12 or a == 0) and (b > 12 or b == 0):
	print("NA")
elif a > 12 or a == 0:
	print("YYMM")
elif b > 12 or b == 0:
	print("MMYY")
else: print("AMBIGUOUS")
S = input()
a = S[0:2]
b = S[2:4]
A = int(a)
B = int(b)
if A>=1 and A <=12:
  if B>= 1 and B <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if B>= 1 and B<= 12:
    print("YYMM")
  else:
    print("NA")
def f(s):
  m,y = int(s[:2]), int(s[2:])
  return (0 < m <= 12,0 < y <= 12)

print {(0,0):'NA', (0,1): 'YYMM', (1,0): 'MMYY', (1,1):'AMBIGUOUS'}[tuple(map(int,list(f(raw_input()))))]
s = int(input())
a = s // 100
b = s % 100

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 = list(input())
x = int("".join(S[0:2]))
y = int("".join(S[2:4]))
if 1 <= x <= 12:
    if 1 <= y <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= y <= 12:
        print("YYMM")
    else:
        print("NA")
pass
S = input()
LL,RR = int(S[:2]), int(S[2:])

def v_month(x):
    return  1<=x and x<=12

def v_year(x):
    return 0<=x

m1 = v_month(LL)
y1 = v_year(LL)

m2 = v_month(RR)
y2 = v_year(RR)

if (m1 and y1) and (m2 and y2):
    print("AMBIGUOUS")
elif m1 and y2:
    print("MMYY")
elif y1 and m2:
    print("YYMM")
else:
    print("NA")
s=input()
a=int(s[:2])
b=int(s[2:])
l=list(range(1,13))
ans="NA"
if a not in l and b in l:
    ans="YYMM"
elif a in l and b not in l:
    ans="MMYY"
elif a in l and b in l:
    ans="AMBIGUOUS"
print(ans)
S  = input()
if (int(S[:2]) == 0 or int(S[:2]) >= 13) and 1 <= int(S[2:]) <= 12:
    print('YYMM')
elif (int(S[2:]) == 0 or int(S[2:]) >= 13) and 1 <= int(S[:2]) <= 12 :
    print('MMYY')
elif 1 <= int(S[2:]) <= 12 and 1 <= int(S[:2]) <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
s = input()
a = int(s[:2])
b = int(s[2:])

if 1 <= a and a <= 12 and 1 <= b and b <=12:
    print("AMBIGUOUS")
elif 1 <= a <=12 and (12 < b or b < 1):
    print("MMYY")
elif (12 < a or a < 1) and 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")
s = input()
ans = {(False, False): 'NA', (False, True): 'YYMM', (True, False): 'MMYY', (True, True): 'AMBIGUOUS'}
print(ans[1 <= int(s[:2]) <= 12, 1 <= int(s[2:]) <= 12])
S=input()
a=int(S[:2]); b=int(S[2:])
if 0<a and a<13 and 0<b and b<13: print('AMBIGUOUS')
elif 0<a and a<13: print('MMYY')
elif 0<b and b<13: print('YYMM')
else: print('NA')
s = input().rstrip()

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

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

s = ns()
x, y = int(s[:2]), int(s[2:])

if x >= 1 and x <= 12:
	if y >= 1 and y <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if y >= 1 and y <= 12:
		print("YYMM")
	else:
		print("NA")
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 or 12 < tmp:
    my = False

tmp = ''
for i in range(2):
    tmp += s[i+2]
tmp = int(tmp)
if tmp < 1 or 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()


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")
s=list(input())
s1=s[0]+s[1]
s2=s[2]+s[3]

if 1<=int(s1)<=12 and 1<=int(s2)<=12:print('AMBIGUOUS')
elif 1<=int(s1)<=12 and 0<=int(s2)<=99:print('MMYY')
elif 1<=int(s2)<=12 and 0<=int(s1)<=99:print('YYMM')
else:print('NA')
import sys

INPUT = lambda: sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)


def main():
    S = INPUT()

    b = 0
    for i in range(2):
        if 0 < int(S[2*i:2*i+2]) <= 12: b += i + 1

    if b == 0: print("NA")
    elif b == 1: print("MMYY")
    elif b == 2: print("YYMM")
    else: print("AMBIGUOUS")


if __name__ == '__main__':
    main()
s = input()

a, b = int(s[:2]), int(s[2:])
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")
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode()

is_YYMM = 1 <= int(S[2:]) <= 12
is_MMYY = 1 <= int(S[:2]) <= 12

if is_YYMM and is_MMYY:
    print('AMBIGUOUS')
elif is_YYMM:
    print('YYMM')
elif is_MMYY:
    print('MMYY')
else:
    print('NA')
import datetime


def is_YYMM(s: str) -> bool:
    try:
        datetime.datetime.strptime(s, "%y%m")
    except ValueError:
        return False
    else:
        return True


def is_MMYY(s: str) -> bool:
    try:
        datetime.datetime.strptime(s, "%m%y")
    except ValueError:
        return False
    else:
        return True


S = input()
if is_MMYY(S) and is_YYMM(S):
    print("AMBIGUOUS")
elif is_MMYY(S):
    print("MMYY")
elif is_YYMM(S):
    print("YYMM")
else:
    print("NA")
s = str(input())

mm_f = 0
mm_e = 0

if 0 < int(s[0:2]) <= 12:
    mm_f = 1
if 0 < int(s[2:]) <= 12:
    mm_e = 1

if mm_f == 1 and mm_e == 1:
    print('AMBIGUOUS')
elif mm_f == 1 and mm_e == 0:
    print('MMYY')
elif mm_f == 0 and mm_e == 1:
    print('YYMM')
else:
    print('NA')
s = input()
ans = [0,0]
if 1 <=  int(s[:2]) <= 12:
    ans[0] = 1
if 1 <= int(s[2:]) <= 12:
    ans[1] = 1
print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][ans[0]][ans[1]])
date=input()
if 1<=int(date[:2])<=12:
    if 1 <= int(date[2:]) <= 12:
        print("AMBIGUOUS")
        exit(0)
    else:
        print("MMYY")
        exit(0)
if int(date[2:])==0 or 13 <= int(date[2:]):
    print("NA")
    exit(0)
print("YYMM")
s = int(input())
s1 = s // 100
s2 = s % 100
if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print("AMBIGUOUS")
elif 1 <= s2 <= 12:
    print("YYMM")
elif 1 <= s1 <= 12:
    print("MMYY")
else:
    print("NA")
S = input()

def M(x):
  if 1 <= int(x) <= 12:
    return 1
  else:
    return 0

L = M(S[:2])
R = M(S[2:])

if L == 1:
  if R == 1:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if R == 1:
    print("YYMM")
  else:
    print("NA")
s=input()
f=int(s[:2])
b=int(s[2:])
if f>=13 or f==0:
	if 0<b and b<13:
		print("YYMM")
	else:
		print("NA")
elif 0<f and f<13:
	if 0<b and b<13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	print("NA")
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


s = int(input())
# print(s)
# print(s//100)
#print(s % 100)
a = s//100
b = s % 100
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()
a, b = int(s[:2]), int(s[2:])
if 1 <= a <= 12:
    if 1 <= b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= b <= 12:
        print("YYMM")
    else:
        print("NA")
S=input()
A=int(S[0:2])
B=int(S[2:4])
if 1<=A<=12:
    if 1<=B<=12:
        ans="AMBIGUOUS"
    else:
        ans="MMYY"
else:
    if 1<=B<=12:
        ans="YYMM"
    else:
        ans="NA"
print(ans)
S = list(str(input()))

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

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

F = int(S[:2])
B = int(S[2:])

if F == 0 and B == 0:
    print('NA')
elif (F == 0 and B > 12) or (B == 0 and F > 12):
    print('NA')
elif F == 0:
    print('YYMM')
elif B == 0:
    print('MMYY')
elif (F <= 12 and B <= 12):
    print('AMBIGUOUS')
elif F > 12 and B <= 12:
    print('YYMM')
elif F <= 12 and B > 12:
    print('MMYY')
else:
    print('NA')
S = input()
F = int(S[0] + S[1])
B = int(S[2] + S[3])
if min(F, B) > 12 or max(F, B) == 0 or min(F,B) == 0 and max(F, B) > 12:
  print('NA')
elif min(F, B) != 0 and max(F, B) <= 12:
  print('AMBIGUOUS')
elif F <= 12 and F != 0:
  print('MMYY')
else:
  print('YYMM')
S = input()
l,r = int(S[:2]),int(S[2:])
if 1 <= l <= 12 and 1 <= r <= 12:
	print("AMBIGUOUS")
elif 1<=r<=12:
	print("YYMM")
elif 1<=l<=12:
	print("MMYY")
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 <= a <= 12 and (b==0 or 13 <= b):
	print('MMYY')
elif 1 <= b <= 12 and (a==0 or 13 <= a):
	print('YYMM')
else:
	print('NA')
s=input()
if (0<=int(s[:2])<=99 and 1<=int(s[2:])<=12) and not(0<=int(s[2:])<=99 and 1<=int(s[:2])<=12):
    print("YYMM")
elif (0<=int(s[2:])<=99 and 1<=int(s[:2])<=12) and not((0<=int(s[:2])<=99 and 1<=int(s[2:])<=12)):
    print("MMYY")
elif (0<=int(s[:2])<=99 and 1<=int(s[2:])<=12) and (0<=int(s[2:])<=99 and 1<=int(s[:2])<=12):
    print("AMBIGUOUS")
else:
    print("NA")
S = input()
LL = int(S[0]+S[1])
RR = int(S[2]+S[3])
# YY or MM
L = ""
if LL == 0 or LL > 12:
    L = "YY"
else:
    L = "YY or MM"

if L == "YY":
    if RR == 0 or RR > 12:
        print("NA")
    elif 1 <= RR <= 12:
        print("YYMM")
elif L == "YY or MM":
    if RR == 0 or RR > 12:
        print("MMYY")
    elif 1 <= RR <= 12:
        print("AMBIGUOUS")
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")