peterverebics/CodeNet_Python_118 huggingface dataset:
s = input()
if (int(s[:2]) > 12)&(int(s[2:]) <= 12)&("00" not in s):
    print("YYMM")
    
elif (int(s[:2]) <= 12)&(int(s[2:]) > 12)&("00" not in s):
    print("MMYY")

elif (int(s[:2]) <= 12)&(int(s[2:]) <= 12)&("00" not in s):
    print("AMBIGUOUS")

else:
    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 <= 12 and b <= 12:
    print("AMBIGUOUS")
elif a <= 12:
    print("MMYY")
elif b <= 12:
    print("YYMM")
else:
    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")
n=input()
a=int(n[0:2])
b=int(n[2:4])
if a<13 and b<13:
    print('AMBIGUOUS')
elif a>0 and a<13:
    print('MMYY')
elif 0<b and b<13:
    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 and int(year) != 0 and int(month) != 0:
    print('AMBIGUOUS')
elif int(month) > 12 and int(month) != 0 and int(year) == 0:
    print('MMYY')
elif int(year) > 12 and int(year) != 0 and int(month) != 0:
    print('YYMM')
else:
    print('NA')
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
elif 0<=x<=99 and 1<=x<12:
  print('YYMM')
else:
  print('NA')
S = input()
F = int(S[0:2])
SE = int(S[2:4])

if F > 12 and SE > 12:
  print("NA")

if F > 12 and SE <= 12:
  print("YYMM")

if F <= 12 and SE > 12:
  print("MMYY")

if F <= 12 and SE <= 12:
  print("AMBIGUOUS")
S = list(input())

ans = []

A = int(S[0] + S[1])
B = int(S[2] + S[3])

if (1 <= A <= 12 and 1 <= B <= 12):
  print("AMBIGUOUS")
elif (1 <= A <= 12 and 13 <= B <= 99):
  print("MMYY")
elif (1 <= B <= 12 and 13 <= A <= 99):
  print("YYMM")
else:
  print("NA")
s = input()
l = s[:2]
r = s[2:]

if(int(l) <=12 and int(r) <= 12):
    print('AMBIGUOUS')
else :
    if(int(l) <= 12):
        print('MMYY')
    else:
        if(int(r) <= 12):
            print('YYMM')
        else:
            print('NA')
s=input()
a=int(s[0:2])
b=int(s[2:])
if 1<=a<=99 and 1<=b<=31:
    if 1<=a<=12 and 1<=b<=12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
elif 1<=b<=99 and 1<=a<=31:
    print('MMYY')
else:
    print('NA')
#B
s = list(input())
left = int(s[0])*10+int(s[1])
right = int(s[2])*10+int(s[3])
print(left,right)
if 0 < left <= 12:
    if 0 < right <= 12:
        print("AMBIGUOUS")
    else:
        print('MMYY')
elif 0 < right <= 12:
    print('YYMM')
else:
    print('NA')
s = input()

f = (0 < int(s[:2]) < 12)
s = (0 < int(s[2:]) < 12)
ans = 'NA'
if f:
    ans = 'YYMM'
elif s:
    ans = 'MMYY'
elif f and s:
    ans = 'AMBIGUOUS'
print(ans)
s=input()
if s[0] == '0':
    if s[-2] == '0':
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif s[-2] == '0':
    print("YYMM")
else:
    print("NA")
S=input()

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

if(1<=a<=12 and 1<=b<=12):
  print("AMBIGUOUS")
elif(1<=a<=12):
  print("mmyy")
elif(1<=b<=12):
  print("yymm")
else:
  print("na")
a,b,c,d=map(int,input())
x=int(a+b)
y=int(c+d)
if 0<=x<=12 and 0<=b<=12:
  if x==y==0:
    print('NA')
  else:
    print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')
S = str(input())
front = int(S[:2])
back = int(S[2:])
S_list = list(S)

if front > 12 or front == 0:
    if 1 < back <= 12 :
        print("YYMM")
    else:
        print("NA")
elif front <= 12 and front == 0:
    if back <= 12 or back > 1: 
        print("AMBIGUOUS")
    else:
        print("MMYY")
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 my:
  print('MMYY')
else:
  print('NA')
S = input()
f,e = int(S[:2]),int(S[2:])
if f==0 or e==0 or (f>12 and e>12):
  print('NA')
  exit()
if 1<=f<=12:
  if e>12:
    print('MMYY')
  elif 1<=e<=12:
    print('AMBIGUOUS')
elif f>12:
  if 1<=e<=12:
    print('YYMM')
#ABC126 B

S = list(map(int,input()))
if S[0]*10 + S[1] <= 12 and S[2]*10 + S[3] <= 12:
    print("AMBIGUOUS")
elif S[0]*10 + S[1] <= 12 and S[2]*10 + S[3] > 12:
    print("MMYY")
elif S[0]*10 + S[1] > 12 and S[2]*10 + S[3] <= 12:
    print("YYMM")
elif S[0]*10 + S[1] > 12 and S[2]*10 + S[3] > 12:
    print("NA")
def main():
    s = int(input())
    f = s/100
    b = s%100

    if f > 0 and f <= 12:
        if b > 0 and b <= 12:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if b > 0 and b <= 12:
            print("YYMM")
        else:
            print("NA")

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

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")
S = list(input())

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

if S[0:2] in M and not(S[2:] in M):
    print("MMYY")
elif not(S[0:2] in M) and S[2:] in M:
    print("YYMM")
elif S[0:2] in M and S[2:] in M:
    print("AMBIGUOUS")
else:
    print("NA")
S = str(input())
year = int(S[0] + S[1])
month = int(S[2] + S[3])
if year <= 12 and year >= 1 and month >= 1 and month <= 12:
    print('AMBIGUOUS')
elif year >= 1 and year <= 99 and month >= 1 and month <= 12:
    print('YYMM')
elif year >= 12 and year <= 12 and month >= 1 and month <= 99:
    print('MMYY')
else:
    print('NA')
S = input()
f, r = int(S[:2]), int(S[2:])
#print(f)
#print(r)
if f == 0 or r == 0 or (f > 12 and r > 12):
  ans = "NA"
elif f > 12 and r <= 12:
  ans = "YYMM"
elif f <= 12 and r > 12:
  ans = "MMYY"
elif r <= 12 and f <= 12:
  ans = "AMBIGUOUS"
print(ans)
s = input()
a = int(s[:2])
b = int(s[2:])
if a<=12 and 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 = input()
head = int(s[:2])
tail = int(s[2:])
if head > 12 and 0 < tail <= 12:
    print("YYMM")
elif 0 < head <= 12 and tail > 12:
    print("MMYY")
elif head <= 12 and tail <= 12:
    print("AMBIGUOUS")
else:
    print("NA")
s = input()

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

    if (int(a) >= 13 and int(b) >= 13) or (a == "00" and b == "00"):
        ans = "NA"
    elif (int(a) >= 13 and b == "00") or (int(b) >= 13 and a == "00"):
        ans = "NA"
    elif int(a) >= 13:
        ans = "YYMM"
    elif int(b) >= 13:
        ans = "MMYY"
    else:
        ans = "AMBIGUOUS"
    print(ans)


if __name__ == "__main__":
    main()
s = input()
a = int(s[0:2])
b = int(s[2:4])
if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif a > 12 and b > 12 or a == 0 or b == 0:
    print("NA")
elif a > 12:
    print("YYMM")
else:
    print("MMYY")
s = input()

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

if upper <= 0 or lower <= 0:
    print('NA')
    exit()

if upper > 12:
    if lower > 31: print('NA')
    else: print('YYMM')
else:
    if lower > 31: print('MMYY')
    else: print('AMBIGUOUS')
S = input()
if 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12:
    print("AMBIGUOUS")
elif int(S[:2]) > 12:
    print("YYMM")
elif int(S[2:]) > 12:
    print("MMYY")
else:
    print("NA")
S = int(input())

A = S//100
B = S%100

if A >= 13:
    if B >= 13:
        print('NA')
    elif B <13:
        if B != 0:
            print('YYMM') 
        else:
            print('NA')
elif A < 13:
    if B >= 13:
        if A != 0:
            print('MMYY')
        else:
            print('NA')
    elif B < 13:
        print('AMBIGUOUS')
S = input()
year_list = ["01","02","03","04","04","05","06","07","08","09","10","11","12"]

if S[0:2] in year_list:
    if S[2:4] in year_list:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if S[2:4] in year_list:
        print("MMYY")
    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 > 13:
  print("MMYY")
elif fo > 13 and la <= 12:
  print("YYMM")
else:
  print("NA")
S = input()
F = int(S[:2])
L = int(S[2:])

if (F >= 13 and L >= 13) or (F == 0 and L == 0):
    print('NA')
elif F >= 13 or F == 0:
    print('YYMM')
elif L >= 13 or L == 0:
    print('MMYY')
else:
    print('AMBIGUOUS')
s = input()

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

if former==0 or later==0 or (former>31 and later>31):
  print("NA")
elif former<13 and later<13:
  print("AMBIGUOUS")
elif former<13 and later<32:
  print("MMYY")
elif former<32 and later<13:
  print("YYMM")
def solve():
    S = input()
    l = int(S[:2])
    r = int(S[2:])
    
    if l == 0 or r == 0:
        return 'NA'
    if l >= 20 or r >= 20:
        return 'NA'

    if 12 < l <= 19 and r <= 12:
        return 'YYMM'
    elif l <= 12 and r <= 19:
        return 'MMYY'
    elif l <= 12 and r <= 12:
        return 'AMBIGUOUS'
    else:
        return 'NA'

print(solve())
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 and 0<b<=12:
  print("AMBIGUOUS")
elif 0<a<12:
  print("MMYY")
else:
  print("YYMM")
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    S = input()

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

    if first == 0 or second == 0:
        print('NA')
    elif first > 12 and second > 12:
        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()
a = input()
frm = int(a[:2])
lat = int(a[2:])


if frm >= 12 and lat >= 12:
    print('NA')
elif frm <= 12 and lat > 12:
    if 0<frm:
        print('MMYY')
    else:
        print('NA')    
elif frm > 12 and  lat <= 12:
    if lat > 0:
        print('YYMM')
    else:
        print('NA')
elif frm <= 12 and lat==0:
    print('MMYY')
elif frm == 0 and  lat <= 12:
    print('YYMM')
else:
    print('AMBIGUOUS')
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) <= 12 and int(ju2) > 12:
        print('MMYY')
    if int(ju1) > 12 and int(ju2) <= 12:
        print('YYMM')
    if int(ju1) <= 12 and int(ju1) <= 12:
        print('AMBIGUOUS')
else:
    print('NA')
S=input()
a=int(S[0]+S[1])
b=int(S[2]+S[3])
if (a==0 or a>12) and 0<b<=12:
    print("YYMM")
elif 0<a<=12 and 0<b<=12:
    print("AMBIGUOUS")
elif 0<a<=12 and b>12:
    print("MMYY")
else:
    print("NA")
S = input()
if int(S[:2]) == 0 or int(S[3:]) ==0:
    print('NA')
elif int(S[:2]) > 12 and int(S[3:]) >12:
    print('NA')
elif int(S[:2]) > 12 and int(S[3:]) <=12:
    print('YYMM')
elif int(S[:2]) <= 12 and int(S[3:]) >12:
    print('MMYY')
elif int(S[:2]) <= 12 and int(S[3:]) <= 12:
    print('AMBIGUOUS')
s = input()
a = s[:2]
b = s[2:4]
a = int(a)
b = int(b)
ok_a = True
ok_b = True
if a == 0 or b == 0:
    print('NA')
    exit()
if a > 12: ok_a = False
if b > 12: ok_b = False
if ok_a == 1 and ok_b == 1: print('AMBIGUOUS')
elif ok_a == 1 and ok_b == 0: print('MMYY')
elif ok_a == 0 and ok_b == 1: print('YYMM')
else: print('NA')
s=input()
fs=int(s[:2])
ls=int(s[2:])
if 1<=fs<=12 and 13<=ls:
    print('MMYY')
elif 1<=fs<=12 and 1<=ls<=12:
    print('AMBIGUOUS')
elif fs>=13 and 1<=ls<=12:
    print('YYMM')
else:
    print('NA')
n=input()

n1,n2=int(n[:2]),int(n[2:])
if n1>12 and n2>12 or n1==0 or n2==0:
    print("Na")
elif (n1!=0 and n1<=12) and (n2!=0 and n2<=12):
    print("AMBIGUOUS")
elif n1!=0 or n1<=12:
    print("MMYY")
elif n2!=0 or n2<=12:
    print("YYMM")
else:
    print("errer")
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    S = input()

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

    if first == 0 or second == 0:
        print('NA')
    elif first > 0 and 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()
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")
  else:
    print("YYMM")
elif c>12 or c==0:
  if b>12 or b==0:
    print("Na")
  else:
    print("MMYY")
else:
  print("AMBIGUOUS")
S = input()
S1, S2 = S[0:2], S[2:5]
if int(S1) > 12 and (int(S2) >= 1 and int(S2) <= 12):
	print('YYMM')
elif (int(S1) >= 1 and int(S1) <=12) and int(S2) > 12:
	print('MMYY')
elif (int(S1) >= 1 and int(S1) <=12) and (int(S2) >= 1 and int(S2) <=12):
	print('AMBIGUOUS')
else:
	print('NA')
S=input()
x=int(S[:2])
y=int(S[2:])
if x<=12:
    if y<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if y<=12:
        print("YYMM")
    else:
        print("NA")
s=input()
YY=[]
MM=["01","02","03","04","05","06","07","08","09","10","11","12"]

for i in range(13,100):
    YY.append(str(i))

if s[:2] in YY and s[2:] in MM:
    print("YYMM")
elif s[:2] in MM and s[2:] in YY:
    print("MMYY")

elif s[:2] in MM and s[2:] in MM:
    print("AMBIGUOUS")
elif s[:2] in YY and s[2:] in YY:
    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("YYMM")
elif (1 <= b <= 12):
    print("MMYY")
else:
  print("NA")
S = input()
year_list = ["01","02","03","04","04","05","06","07","08","09","10","11","12"]

if S[0:2] in year_list:
    if S[2:4] in year_list:
        print("AMBIGUOUS")
    elif S[2:4] == "00":
        print("NA")
    elif int(S[2:4]) >= 32:
        print("NA")
    else:
        print("YYMM")
elif S[0:2] == "00":
    print("NA")
elif int(S[0:2]) >= 32:
    print("NA")
else:
    if S[2:4] in year_list:
        print("MMYY")
    else:
        print("NA")
S = input()
f,e = int(S[:2]),int(S[2:])
if f==0 or e==0 or (f>12 and e>12):
  print('NA')
else:
  if 1<=f<=12 and e>12:
    print('MMYY')
  elif f>12 and 1<=e<=12:
    print('YYMM')
  else:
    print('AMBIGUOUS')
S = list(input())
a = S[0] + S[1]
b = S[2] + S[3]
A = int(a)
B = int(b)

if (0 < A < 13 and 0 < B < 13):
  print("AMBIGUOUS")
elif (0 < A < 13 and 12 < B <= 99):
  print("MMYY")
elif (0 < B < 13 and 12 < A <= 99):
  print("YYMM")
else:
  print("NA")
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


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

if 1 <= f <= 12 and 1 <= l <= 12:
    print('AMBIGUOUS')

elif 1 <= l <= 12 and f > 12:
    print('YYMM')

elif 1 <= f <= 12 and l > 12:
    print('MMYY')

else:
    print('NA')
S = input()
l = S[:2]
r = S[2:]

lcnt = 0
rcnt = 0
if 0 < int(l) <= 12 and 0 < int(r):
    lcnt = 1
if  0 < int(r) <= 12 and 0 < int(l):
    rcnt = 1
if lcnt and rcnt:
    print('AMBIGUOUS')
    exit()
elif lcnt:
    print('MMYY')
elif rcnt:
    print('YYMM')
else:
    print('NA')
s = input()
f, b = int(s[:2]), int(s[2:])
if (f == 0 or b == 0): print("NA")
elif (f > 12 and b > 12): print("NA")
elif (f > 12): print("YYMM")
elif (b > 12): print("MMYY")
else: print("AMBIGUOUS")
s = input()

#s = list(s)

mae = int(s[:2])
usi = int(s[2:])
#print(mae,usi)


if(mae >= 0 and mae <= 99 or usi >= 1 and usi <= 12):
  print("AMBIGUOUS")
elif(usi >= 0 and usi <= 99 or mae >= 1 and mae <= 12):
  print("AMBIGUOUS")
elif(mae == 0 and usi == 0):
  print("NA")
elif(mae == 0 and usi >= 12):
  print("NA")
elif(mae >= 12 and usi == 0):
  print("NA")
elif(mae >= 0 and mae <= 99 and usi >= 1 and usi <= 12):
  print("YYMM")
elif(usi >= 0 and usi <= 99 and mae >= 1 and mae <= 12):
  print("MMYY")
else:
  print("AMBIGUOUS")
s = input()

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

if former==0 or later==0 or (former>31 and later>31):
  print("NA")
elif former<13 and later<13:
  print("AMBIGUOUS")
elif former<13 and later<32:
  print("MMYY")
elif former<32 and later<13:
  print("YYMM")
else:
  print("NA")
s = input()

s_u, s_l = int(s[:2]), int(s[2:])
if s_u > 12 and 1 <= s_l <= 12:
    print('YYMM')
elif 1 <= s_u <= 12 and s_l > 12:
    print('MMYY')
elif s_u == 0 or s_l == 0:
    print('NA')
else:
    print('AMBIGUOUS')
A = str(input())
AC = list(A)
AB = int(A[0] + A[1])
AC = int(A[2] + A[3])

if 1 <= AB <= 12 and 1 <= AC <= 12:
    print("AMBIGUOUS")
elif AB > 13:
    print("YYMM")
elif AC > 13:
    print("MMYY")
else:
    print("NA")
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7


s = input()
if s[:2] == '00' or s[2:] == '00':
    print('NA')
    exit()
    
a = (1 <= int(s[:2]) <= 12)
b = (1 <= int(s[2:]) <= 12)

if a and b:
    print('AMBIGUOUS')
elif a and (not b):
    print('MMYY')
elif (not a) and b:
    print('YYMM') 
else:
    print('NA')
S = input()
up = int(S[0:2])
down = int(S[2:4])

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

def month(n):
    if n <= 12:
        return True
    else:
        return False

if month(int(s[0:2])):
    if month(int(s[2:4])) and int(s[2:4]) != 0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if month(int(s[2:4])) and int(s[2:4]) != 0:
            print("YYMM")
    else:
        print("NA")
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):
  if b >= 1 and b <= 12:
    print('AMBIGIOUS')
  else:
    print('MMYY')
elif b >= 1 and b <= 12:
  print('YYMM')
else:
  print('NA')
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")
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
elif 0<=x<=99 and 1<=y<12:
  print('YYMM')
else:
  print('NA')
# 126 B

s = input()

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

if fir > 0 and sec > 0:
    if 1 <= fir <= 12 and 1 <= sec <= 12 :
        print("AMBIGUOUS")
    elif 1 <= fir <= 12: 
        print("MMYY")
    elif 1 <= sec <= 12:
        print("YYMM") 
    else:
        print("NA")
else:
    print("NA")
s = input()
#print(s[2])
#print(int(s[0] + s[1]))

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

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

if 0 < a and a <= 12 and 0 < b and b <= 12:
  print("AMBIGUOUS")
elif a > 12 and 0 < b and b <= 12:
  print("YYMM")
elif 0 < a and a <= 12 and b > 12:
  print("MMYY")
else:
  print("NA")
# input
S = input()
x, y = S[:2], S[2:]

# check
not_YY_x = (int(x) >= 13)
not_YY_y = (int(y) >= 13)
zero_x = (x == "00")
zero_y = (y == "00")
checker = [not_YY_x, not_YY_y, zero_x, zero_y]

if checker == [True, False, False, False]:
    print("YYMM")
elif checker == [False, True, False, False]:
    print("MMYY")
elif checker == [False, False, False, False]:
    print("AMBIGUOUS")
else:
    print("NA")
s = input()


if int(s[:2]) <= 12 or int(s[2:]) <= 12:
    if int(s[:2]) <= 12 and 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')
else:
    print('NA')
#!/usr/bin/env python3

s = str(input())

a = s[0:2]

b = s[2:]


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


if div(a) == div(b):
    if div(a) == "YY":
        print("NA")
    else:
        print("AMBIGUOUS")
elif div(a) == "YY":
    print(b+a)
else:
    print(a+b)
a = input()
frm = int(a[:2])
lat = int(a[2:])


if frm > 12 and lat > 12:
    print('NA')
elif frm <= 12 and lat > 12:
    if 0<frm:
        print('MMYY')
    else:
        print('NA')    
elif frm > 12 and  lat <= 12:
    if lat > 0:
        print('YYMM')
    else:
        print('NA')
elif frm <= 12 and lat==0:
    print('MMYY')
elif frm == 0 and  lat <= 12:
    print('YYMM')
else:
    print('AMBIGUOUS')
s = 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('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])
ans=""
if s1>12:
	if s2>12:
		ans="NA"
	else:
		ans="YYMM"
else:
	if s2>12:
		ans="MMYY"
	else:
		ans="AMBIGUOUS"
print(ans)
S = input()
if int(S[:2]) == 0 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:
    print('YYMM')
elif int(S[2:]) >= 13 and int(S[:2]) < 13:
    print('MMYY')
else:
    print('AMBIGUOUS')
S = input()
f, r = int(S[:2]), int(S[2:])
#print(f)
#print(r)
if f > 12 and 0 < r <= 12:
  ans = "YYMM"
elif 0 < f <= 12 and r > 12:
  ans = "MMYY"
elif 0 < r <= 12 and 0 < f <= 12:
  ans = "AMBIGUOUS"
else:
  ans = "NA"
print(ans)
s = input()

s_u, s_l = int(s[:2]), int(s[2:])
if s_u > 12 and 1 <= s_l <= 12:
    print('YYMM')
elif 1 <= s_u <= 12 and s_l > 12:
    print('MMYY')
elif 1 <= s_u <= 12 and 1 <= s_l <= 12:
    print('AMBIGUOUS')
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('AMBIGUOUS')
S = input()

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

if F > 12 and B > 12:
    print('NA')
elif F == 0 and B > 12:
    print('NA')
elif B == 0 and F > 12:
    print('NA')
elif F <= 12 and B <= 12:
    print('AMBIGUOUS')
elif B <= 12:
    print('YYMM')
else:
    print('MMYY')
s=str(input())
a,b=int(s[:2]),int(s[2:])
print(a,b)
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()
a = int(s[0:2])
b = int(s[2:4])
if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif (a > 12 and b > 12) or a == 0 or b == 0:
    print("NA")
elif a > 12:
    print("YYMM")
elif b > 12:
    print("MMYY")
s = list(input())
head = int(s[0] + s[1])
tail = int(s[2] + s[3])
if (12 < head < 100) and (0 < tail < 13):
    print('YYMM')
elif (0 < head < 13) and (12 < tail < 100):
    print('MMYY')
elif (0 < head < 13) and (0 < tail < 13):
    print('AMBIGUOUS')
else:
    print('NA')