peterverebics/CodeNet_Python_118 huggingface dataset:
S = int(input())

flag = [0, 0] # [YYMM, MMYY]
l = S // 100
r = S % 100
if 1<=r and r<=12:
  flag[0] += 1
if 1<=l and l<=12:
  flag[1] += 1
if flag == [0, 0]:
  print('NA')
elif flag == [0, 1]:
  print('MMYY')
elif flag == [1, 0]:
  print('YYMM')
elif flag == [1, 1]:
  print("AMBIGUOUS")
s = input()
n1 = int(s[0:2])
n2 = int(s[2:4])

if 1 <= n1 <= 12:
  if 1 <= n2 <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif 1 <= n2 <= 12:
  print('YYMM')
else:
  print('NA')
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')
s = input()
sa = int(s[:2])
sb = int(s[2:])

if sa >= 1 and sa <= 12 and sb >= 1 and  sb <= 12:
    print('AMBIGUOUS')
    exit()
else:
    if sa >= 1 and sa <= 12:
        print('MMYY')
        exit()
    if sb >= 1 and sb <= 12:
        print('YYMM')
        exit()

print('NA')
def main():
    S = input()
    a = S[0:2]
    b = S[2:4]

    if 1 <= int(a) <= 12:
        if 1 <= int(b) <= 12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if 1 <= int(b) <= 12:
            print("YYMM")
        else:
            print("NA")


if __name__ == "__main__":
    main()
S = input()
sform = int(S[:2])
slatt = int(S[2:])

if sform <= 12 and sform >= 1:
    if slatt <= 12 and slatt >= 1:
        print('AMBIGUOUS')
    else:
        print('MMYY')

else:
    if slatt <= 12 and slatt >= 1:
        print('YYMM')
    else:
        print('NA')
S=input()
x=int(S[:2])
y=int(S[2:])

if 1<=x<=12 and 1<=y<=12:
    print("AMBIGUOUS")
elif 1<=x<=12:
    print("MMYY")
elif 1<=y<=12:
    print("YYMM")
else:
    print("NA")
input_s = input()
head_num = int(input_s[:2])
bottom_num = int(input_s[2:])
yymm_flag = 0
mmyy_flag = 0

if bottom_num <= 12 and bottom_num != 0:
    yymm_flag += 1


if head_num <= 12 and head_num != 0:
    mmyy_flag += 1
    
if yymm_flag == 1 and mmyy_flag == 1:
    print("AMBIGUOUS")
elif yymm_flag == 1:
    print("YYMM")
elif mmyy_flag == 1:
    print("MMYY")
else:
    print("NA")
def main():
    s  = int(input())
    k = s//100
    t = s%100

    if(k>0 and k<13) and (t>0 and t<13):
        res = "AMBIGUOUS"
    elif(k>0 and k<13):
        res = "MMYY"
    elif(t>0 and t<13):
        res = "YYMM"
    else:
        res = "NA"
    print(res)






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

left = int(s/100)
right = int(s%100)


if left > 12 or left <= 0:
    if right > 12 or right <= 0:
        print('NA')
    else:
        print('YYMM')
else:
    if right > 12 or right <= 0:
        print('MMYY')
    else:
        print('AMBIGUOUS')
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("AMBIGUOUS")
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")
s = list(input())
a = int(s[0]+s[1])
b = int(s[2]+s[3])

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

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

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

if (l > 0 and l < 13) and (r > 0 and r < 13):
    ret = 'AMBIGUOUS'
elif (l > 0 and l < 13) and (r == 0 or r >= 13):
    ret = 'MMYY'
elif (l == 0 or l >= 13) and (r > 0 and r < 13):
    ret = 'YYMM'
else:
    ret = 'NA'

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

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

if  1 <= A and A <= 12:
    if  1 <= B and B <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if  1 <= B and B <= 12:
        print("YYMM")
    else:
        print("NA")
S = str(input())
s1,s2 = int(S[:2]),int(S[2:])
c1,c2 = 0,0

if 0 < s1 < 13:
  c1 = 1
if 0 < s2 < 13:
  c2 = 1

if c1 and c2:
  ans = "AMBIGUOUS"
elif c1:
  ans = "MMYY"
elif c2:
  ans = "YYMM"
else:
  ans = "NA"
print(ans)
s=input();a,b=map(int,(s[:2],s[2:]));print('AMBIGUOUS'if 1<=a<=12 and 1<=b<=12 else'MMYY'if 1<=a<=12 and 0<=b<=99 else'YYMM'if 0<=a<=99 and 1<=b<=12 else'NA')
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])
c = 0
if 0 < a <= 12:
    c += 10
if 0 < b <= 12:
    c += 1
if c == 11:
    print("AMBIGUOUS")
elif c == 10:
    print("MMYY")
elif c == 1:
    print("YYMM")
else:
    print("NA")
s = input()
x = int(s[0:2])
y = int(s[2:4])
if 1 <= x <= 12:
    if 1 <= y <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1 <= y <= 12:
    print("YYMM")
else:
    print("NA")
s = input()

left = int(s[:2])
right = int(s[2:])

if 0 < left <= 12 and 0 < right <= 12:
    print('AMBIGUOUS')
elif 0 < left <= 12 < right or right == 0 < left <= 12:
    print('MMYY')
elif 0 < right <= 12 < left or left == 0 < right <= 12:
    print('YYMM')
else:
    print('NA')
s = int(input())
mae   = s // 100
usiro = s % 100
Mflag = True
Uflag = True

if mae < 1 or mae > 12:
    Mflag = False

if usiro < 1 or usiro > 12:
    Uflag = False

if Mflag:
    if Uflag:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if Uflag:
        print('YYMM')
    else:
        print('NA')
S=str(input())
if int(S[0:2])<=12 and int(S[0:2])>=1:
  if int(S[2:4])<=12 and int(S[2:4])>=1:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if int(S[2:4])<=12 and int(S[2:4])>=1:
    print("YYMM")
  else:
    print("NA")
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

s=input()
p_a=int(s[:2])
p_b=int(s[2:])
yymm=(0<p_b<13)
mmyy=(0<p_a<13)


if yymm and mmyy:
    print("AMBIGUOUS")
    exit()

if yymm:
    print("YYMM")
    exit()
if mmyy:
    print("MMYY")
    exit()

print("NA")
import sys
input = lambda : sys.stdin.readline().rstrip()

s = input()

left = s[:2]
right = s[2:]

months = [str(x).zfill(2) for x in range(1, 13)]

ans = "AMBIGUOUS" if left in months and right in months else "YYMM" if right in months else "MMYY" if left in months else "NA"

print(ans)
x=input()
a=x[:2]
b=x[2:]
ans_lst=[]
for y in [a,b]:
	if "00"<y<"13":
		ans_lst.append(True)
	else:ans_lst.append(False)
if all(ans_lst):
    print("AMBIGUOUS")
elif not any(ans_lst):
    print("NA")
elif ans_lst[0] and ans_lst[1]==False:
	print("MMYY")
elif ans_lst[0]==False and ans_lst[1]:
	print("YYMM")
s = input()

sm = int(s[0:2])
sl = int(s[2:4])

ans = [["NA", "MMYY"],
       ["YYMM", "AMBIGUOUS"]]

qm = (1 <= sm <= 12)
ql = (1 <= sl <= 12)

print(ans[ql][qm])
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")
#n,k = list(map(int,input().split()))
s = input()
a=int(s[:2])
b=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[: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()
if s[0:2] in "01 02 03 04 05 06 07 08 09 10 11 12":
  l = "m"
else:
  l = "y"
if s[2:4] in "01 02 03 04 05 06 07 08 09 10 11 12":
  r = "m"
else:
  r = "y"
if l+r == "mm":
  print("AMBIGUOUS")
elif l+r == "my":
  print("MMYY")
elif l+r == "ym":
  print("YYMM")
else:
  print("NA")
S = input()
L = int(S[0:2])
R = int(S[2:4])
if 0 < L <= 12 and 0 < R <= 12:
    print("AMBIGUOUS")
elif 0 < L <= 12:
    print("MMYY")
elif 0 < R <= 12:
    print("YYMM")
else:
    print("NA")
def month(n):
    if 0 < n and n < 13:
        return True
    else:
        return False


num = input()
if month(int(num[2:])):
    if month(int(num[:2])):
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if month(int(num[:2])):
        print('MMYY')
    else:
        print('NA')
S=list(input())
S1=S[0]+S[1]
S2=S[2]+S[3]
if 13>int(S1)>0:
  if 13>int(S2)>0:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 13>int(S2)>0:
    print("YYMM")
  else:
    print("NA")
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

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

def ismonth(x):
    return 0 < x and x < 13

if ismonth(a) and ismonth(b):
    print("AMBIGUOUS")
elif ismonth(a):
    print("MMYY")
elif ismonth(b):
    print("YYMM")
else:
    print("NA")
S = input()
A = int(S[0]+S[1])
B = int(S[2]+S[3])
if 0 < A <= 12:
    if 0 < B <= 12:
        print('AMBIGUOUS')

    else:
        print('MMYY')

elif A > 12 or A == 0:
    if 0 < B <= 12:
        print('YYMM')

    else:
        print('NA')
S = input()
first = S[:2]
second = S[2:]
if 0 < int(first) and int(first) <= 12 and 0 < int(second) and int(second) <= 12:
    print("AMBIGUOUS")
elif 0 < int(second) and int(second) <= 12:
    print("YYMM")
elif 0 < int(first) and int(first) <= 12:
    print("MMYY")
else:
    print("NA")
s = input()
s1 = s[0 : 2]
s2 = s[2 : 4]
if 1 <= int(s1) <= 12 and 1 <= int(s2) <= 12:
    print("AMBIGUOUS")
elif 1 <= int(s1) <= 12:
    print("MMYY")
elif 1 <= int(s2) <= 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):
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif(1<=B<=12):
    print("YYMM")
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:
  print('MMYY')
elif 1 <= int(N[2]+N[3]) <=12:
  print('YYMM')
else:
  print('NA')
s=int(input())
a=s//100
b=s%100
if a<=12 and a>=1 and b<=12 and b>=1:
  print("AMBIGUOUS")
elif (a>=13 or a==0) and b<=12 and b>=1:
  print("YYMM")
elif a<=12 and a>=1 and (b>=13 or b==0):
  print("MMYY")
else:
  print("NA")
S=input()
forward=""
back=""
yymm=0
mmyy=0
for i in range(4):
    forward=S[:2]
    back=S[2:]
forward=int(forward)
back=int(back)
if ((1<=forward)and(forward<=12)):
    mmyy=1
if ((1<=back)and(back<=12)):
    yymm=1
if (mmyy==1):
    if (yymm==1):
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if(yymm==1):
        print("YYMM")
    else:
        print("NA")
s=int(input())
n1=s//100
n2=s%100
if n1>12 or n1==0:
    if n2>12 or n2==0:print("NA")
    else:print("YYMM")
else:
    if n2>12 or n2==0:print("MMYY")
    else:print("AMBIGUOUS")
# coding: utf-8

S = input()

s1 = int(S[0]) * 10 + int(S[1])
s2 = int(S[2]) * 10 + int(S[3])

if 1 <= s1 <= 12:
	if 1 <= s2 <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 1 <= s2 <= 12:
		print("YYMM")
	else:
		print("NA")
S = int(input())
S1, S2 = S // 100, S % 100

YYMM = (1 <= S2 and S2 <= 12)
MMYY = (1 <= S1 and S1 <= 12)

if YYMM and MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")
S = str(input())
red = int(S[0:2])
blue = int(S[2:4])
if 1<=red<=12:
    if 1<=blue<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=blue<=12:
        print("YYMM")
    else:
        print("NA")
S = input()

if(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")
else:
    print("NA")
S = input()
Fa = int(S[:2])
Se = int(S[2:])
if 1 <= Fa <= 12 and 1 <= Se <= 12:
	print("AMBIGUOUS")
elif 1 <= Fa <= 12:
	print("MMYY")
elif 1 <= Se <= 12:
	print("YYMM")
else:
	print("NA")
S=str(input())
l=int(S[0]+S[1])
r=int(S[2]+S[3])
if l<=12 and l>0 and r<=12 and r>0:
  print('AMBIGUOUS')
elif l<=12 and l>0:
  print('MMYY')
elif r<=12 and r>0:
  print('YYMM')
else:
  print('NA')
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) or (a==0 and b>=13) or (a>=13 and b==0):
  print("NA")
elif 0<a<=12 and 0<b<=12:
  print("AMBIGUOUS")
elif 0<a<=12:
  print("MMYY")
else:
  print("YYMM")
from sys import stdin
S = stdin.readline().rstrip()
front = int(S[:2])
back = int(S[2:])
def bool_mm(input):
    if 0 < input <= 12:
        return True
    else:
        return False 
bool_f = bool_mm(front)
bool_b = bool_mm(back)
if bool_f and bool_b:
    print("AMBIGUOUS")
elif bool_f and ~bool_b:
    print("MMYY")
elif ~bool_f and bool_b:
    print("YYMM")
else:
    print("NA")
n = input()
ans = 0
if 1 <= int(n[0:2]) <= 12 and 0 <= int(n[2:4]) <= 99:
  ans += 1
if 0 <= int(n[0:2]) <= 99 and 1 <= int(n[2:4]) <= 12:
  ans += 3
if ans == 1:
  print('MMYY')
elif ans == 3:
  print('YYMM')
elif ans == 4:
  print('AMBIGUOUS')
else:
  print('NA')
S = input()
A = int(S[0:2])
B = int(S[2:])

if (A<=12 and A>0) and (B>12 or B==0):#A is between 0-12 and B is not month (=year)
    strFormat = "MMYY"
elif (A>12 or A==0) and (B<=12 and B>0):#B is between 0-12 and B is not month(=year)
    strFormat = "YYMM"
elif (A>0 and A<=12 and B>0 and B<=12 ):#both are between 1-12
    strFormat = "AMBIGUOUS"
else:
    strFormat = "NA"

print(strFormat)
S = int(input())
x = S//100
y = S%100
yymm = (1<=y<=12)
mmyy = (1<=x<=12)

ans = "NA"
if yymm and mmyy:
    ans = 'AMBIGUOUS'
elif yymm and not(mmyy):
    ans = 'YYMM'
elif mmyy and not(yymm):
    ans = 'MMYY'

print(ans)
s=input()

if 0<int(s[:2])<=12:
    if 0<int(s[2:])<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0<int(s[2:])<=12:
        print('YYMM')
    else:
        print('NA')
a=input()
 
b = int(a[:2])
c = int(a[2:])
 
if 0< b < 13:
    a_month_flag = 1
    
elif b == 0:
    a_month_flag = 0    
else:
    a_month_flag = 0
 
if 0< c < 13:
    b_month_flag = 1
    
elif c == 0:
    b_month_flag = 0
  
else:
    b_month_flag = 0
 
if a_month_flag ==1 and b_month_flag==1:
    print("AMBIGUOUS")
elif a_month_flag == 1 and b_month_flag == 0:
    print("MMYY")
elif a_month_flag == 0 and b_month_flag ==1:
    print("YYMM")
else:
    print("NA")
s = list(input())
s1 = int("".join(s[:2]))
s2 = int("".join(s[2:]))

if 1 <= s1 <= 12 and 1 <= s2 <= 12:
    print('AMBIGUOUS')
elif 1 <= s1 <= 12:
    print('MMYY')
elif 1 <= s2 <= 12:
    print('YYMM')
else:
    print('NA')
a,b,c,d = list(input())

ab = int(a+b)
cd = int(c+d)

if ab >= 1 and ab <= 12 and cd >= 1 and cd <= 12:
  ans = 'AMBIGUOUS'
else:
  if  ab >= 1 and ab <= 12:
    ans = 'MMYY'
  elif cd >= 1 and cd <= 12:
    ans = 'YYMM'
  else:
    ans = 'NA'

print(ans)
a=str(input())
f=int(a[0:2])
r=int(a[2:4])
if f>=1 and f<=12:
    f1=True
else:
    f1=False

if r>=1 and r<=12:
    r1=True
else:
    r1=False

if f1==True and r1==True:
    print('AMBIGUOUS')
if f1==True and r1==False:
    print('MMYY')
if f1==False and r1==True:
    print('YYMM')
if f1==False and r1==False:
    print('NA')
s = input()

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

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

print(ans)
s=input()
if int(s[:2])<=12 and int(s[:2])>0:
    if int(s[2:4])<=12 and int(s[2:4])>0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif int(s[2:4])<=12 and int(s[2:4])>0:
    print("YYMM")
else:
    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) or (0<a<13 and b==0) ):
  print("MMYY")
if( (12<a<100 and 0<b<13) or (a==0 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")
if( a==0 and b==0 ):
  print("NA")
S = input()

M1_ = True if int(S[:2]) in range(1, 13, 1) else False
M2_ = True if int(S[2:]) in range(1, 13, 1) else False

if M1_:
  if M2_:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif not M1_:
  if M2_:
    print('YYMM')
  else:
    print('NA')
s = input()
n1 = int(s[:2])
n2 = int(s[2:])
if 1 <= n1 <= 12 and 1 <= n2 <= 12:
    print("AMBIGUOUS")
elif (n1 > 12 or n1 == 0) and 1 <= n2 <= 12:
    print("YYMM")
elif 1 <= n1 <= 12 and (n2 > 12 or n2 == 0):
    print("MMYY")
else:
    print("NA")
s = int(input())
a, b = s // 100, 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()
months = [
    '01', '02', '03',
    '04', '05', '06',
    '07', '08', '09',
    '10', '11', '12']
if S[:2] in months and S[2:] in months:
    print('AMBIGUOUS')
elif S[:2] in months:
    print('MMYY')
elif S[2:] in months:
    print('YYMM')
else:
    print('NA')
# -*- coding: utf-8 -*-

def main():

    S = input()

    listS = [int(S[:2]), int(S[2:])]

    if 1 <= listS[0] <= 12 and 1 <= listS[1] <= 12:
        ans = 'AMBIGUOUS'

    elif 1 <= listS[0] <= 12:
        ans = 'MMYY'

    elif 1 <= listS[1] <= 12:
        ans = 'YYMM'

    else:
        ans = 'NA'

    print(ans)


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

# 0 to 99 YY
# 1 to 12 MM

AA = int(S[:2])
BB = int(S[2:])

A = ""
B = ""
ans = ""
if AA == 0 or AA > 12:
    A = "YY"
else:
    A = "MM"
    
if BB == 0 or BB > 12:
    B = "YY"
else:
    B = "MM"
    
if A == "YY" and  B == "YY":
    ans = "NA"
elif A == "YY" and B == "MM":
    ans = "YYMM"
elif A == "MM" and B == "YY":
    ans = "MMYY"
else:
    ans = "AMBIGUOUS"
        
print(ans)
S = input()
n1 = int(S[:2])
n2 = int(S[2:])

if 1 <= n1 <= 12 and 1 <= n2 <= 12:
    print('AMBIGUOUS')
elif 1 <= n1 <= 12 and (not 1 <= n2 <= 12):
    print('MMYY')
elif (not 1 <= n1 <= 12) and 1 <= n2 <= 12:
    print('YYMM')
else:
    print('NA')
s = input()
a = int(s[0:2])
b = int(s[2:])

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

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

if 0 < L <= 12:
    if 0 < R <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0 < R <= 12:
    print('YYMM')
else:
    print('NA')
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    s1=int(s[:2])
    s2=int(s[2:])
    l=list(range(1,13))
    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()
import re

s = input()


def is_valid_yymm(s):
    match = re.search('^[0-9]{2}(01|02|03|04|05|06|07|08|09|10|11|12)$', s)
    return bool(match)
    

def is_valid_mmyy(s):
    match = re.search('^(01|02|03|04|05|06|07|08|09|10|11|12)[0-9]{2}$', s)
    return bool(match)


if is_valid_yymm(s) and is_valid_mmyy(s):
    print('AMBIGUOUS')
elif is_valid_yymm(s):
    print('YYMM')
elif is_valid_mmyy(s):
    print('MMYY')
else:
    print('NA')
S = input()
a, b = int(S[:2]), int(S[2:])
c = set(list(range(1, 12 + 1)))

if a in c and b in c:
    print('AMBIGUOUS')
    exit()
if a in c:
    print('MMYY')
    exit()
if b in c:
    print('YYMM')
    exit()
print('NA')
exit()
s = input()
str1 = int(s[0:2])
str2 = int(s[2:])

if (1 <= str1 <= 12) and (1 <= str2 <= 12):
    print('AMBIGUOUS')
elif (0 <= str1 <= 99) and (1 <= str2 <= 12):
    print('YYMM')
elif (1 <= str1 <= 12) and (0 <= str2 <= 99):
    print('MMYY')
else:
    print("NA")
a,b,c,d=input()
ym,my=int(a+b),int(c+d)
if 0<ym<13 and 0<my<13:
    print('AMBIGUOUS')
elif 0<ym<13:
    print('MMYY')
elif 0<my<13:
    print('YYMM')
else:
    print('NA')
S = int(input())
b=S%100
a=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()
if 1<=int(s[:2])<=12 and 1<=int(s[2:4])<=12:print("AMBIGUOUS")
elif 1<=int(s[:2])<13:print("MMYY")
elif 1<=int(s[2:4])<13:print("YYMM")
else :print("NA")
s = input()
sb = s[:2]
sa = s[2:]
if 1<=int(sb)<=12 and (13 <= int(sa) or int(sa)==0):
    print('MMYY')
elif 1<=int(sa)<=12 and (13 <= int(sb) or int(sb)==0):
    print('YYMM')
elif 1<=int(sb)<=12 and 1<=int(sb)<=12:
    print('AMBIGUOUS')
else:
    print('NA')
def YY_or_MM(K):
    if 0<K<13:
        return "MM"
    else:
        return "YY"
S=str(input())
head=int(S[0:2])
tail=int(S[2:])
ans=YY_or_MM(head)+YY_or_MM(tail)
if ans=="YYYY":
    print("NA")
elif ans=="MMMM":
    print("AMBIGUOUS")
else:print(ans)
s = input()
s1 = int(s[:2])
s2 = int(s[2:4])

if s1 == 0 and s2 == 0:
    print("NA")
    exit()

if (s1 >= 13 or s1 <= 0) and (s2 >= 13 or s2 <= 0):
    print("NA")
elif s1 <= 12 and s1 >= 1 and s2 <= 12 and s2 >= 1:
    print("AMBIGUOUS")
elif s2 >= 13 or s2 == 0:
    print("MMYY")
else:
    print("YYMM")
S=input()
A=int(S[0:2])
B=int(S[2:4])
if (1<=A and A<=12) and (1<=B and B<=12):
  print("AMBIGUOUS")
elif (1<=A and A<=12) and not(1<=B and B<=12):
  print("MMYY")
elif not(1<=A and A<=12) and (1<=B and B<=12):
  print("YYMM")
else:
  print("NA")
S = list(input())

head = int("".join(S[:2]))
tale = int("".join(S[2:]))

if 1 <= head <= 12:
    if 1 <= tale <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1 <= tale <= 12:
    print("YYMM")
else:
    print("NA")
S = input()


def check_mm(x):
    return (0 < int(x) and int(x) <= 12)


if check_mm(S[:2]) and check_mm(S[2:]):
    print("AMBIGUOUS")
elif check_mm(S[:2]) == False and check_mm(S[2:]):
    print("YYMM")
elif check_mm(S[:2]) and check_mm(S[2:]) == False:
    print("MMYY")
else:
    print("NA")
S = input()
f = int(S[0]+S[1])
b = int(S[2]+S[3])

def judge(int):
    if 1 <= int <= 12:
        return 0
    else:
        return 1
ref = [judge(f), judge(b)]

if ref == [1, 1]:
    print("NA")
elif ref == [0, 1]:
    print("MMYY")
elif ref == [1, 0]:
    print("YYMM")
else:
    print("AMBIGUOUS")
s = input()

if 1 <= int(s[2:4]) <= 12 and 1 <= int(s[0:2]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(s[2:4]) <= 12:
    print('YYMM')
elif 1 <= int(s[0:2]) <= 12:
    print('MMYY')
else:
    print('NA')
A = input()
B = A[0:2]
C = A[2:4]
if 12 >= int(B) > 0:
    if 12 >= int(C) > 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 12 >= int(C) > 0:
    print("YYMM")
else:
    print("NA")