peterverebics/CodeNet_Python_118 huggingface dataset:
s = input()
if (int(s[:2]) >= 13 or s[:2] == '00') and (int(s[2:4]) >= 13 or s[2:4] == '00'):
    print('NA')
elif int(s[:2]) <= 12 and int(s[2:4]) <= 12:
    print('AMBIGUOUS')
elif int(s[:2]) <= 12:
    print('MMYY')
elif int(s[:2]) >= 13:
    print('YYMM')
s = input()
mae = int(s[:2])
ato = int(s[3:])

flag1 = 0
flag2 = 0
if 0<mae and mae<=12:
    flag1 = 1
if 0<ato and ato<=12:
    flag2 = 1

if flag1 == 1 and flag2 == 1:
    print('AMBIGUOUS')
elif flag1 == 1:
    print('MMYY')
elif flag2 == 1:
    print('YYMM')
else:
    print('NA')
s = input()

n1 = s[0:2]
n2 = s[2:4]

if int(n1) > 12 and int(n2) > 12:
    out_print = 'NA'

elif int(n1) <= 12 and int(n2) <= 12:
    out_print = 'AMBIGUOUS'

elif int(n1) <= 12 and int(n2) >12:
    out_print = 'MMYY'
    if int(n1) == 0:
        out_print = 'NA'
elif int(n1) > 12 and int(n2) <= 12:
    out_print = 'YYMM'
    if int(n2) == 0:
        out_print = 'NA'

print(out_print)
S = input()

if 1 <= int(S[2] + S[3]) <= 12 and 1 <= int(S[0] + S[1]) <= 12:
  print('AMBIGUOUS')
elif 1 <= int(S[2] + S[3]) <= 12 and not (1 <= int(S[0] + S[1]) <= 12):
  print('YYMM')
elif 1 <= int(S[0] + S[1]) <= 12 and not (1 <= int(S[2] + S[3]) <= 12):
  print('MMYY')
else:
  print('NN')
s = str(input())
a = int(s[0])*10 + int(s[1])
b = int(s[2])*10 + int(s[3])
if a >= 13 and 1 <= b <= 12:
    print("YYMM")
elif 1 <= a <= 12 and b >= 13:
    print("MMYY")
elif 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
else:
    print("NA")
S = int(input())
a = S % 100
b = (S- (S % 100))/100
if  a <= 31 and b <= 12 and b<=31 and a<=12 and a!=0 and b!= 0:
  print("AMBIGUOUS")
elif   a <= 31 and b <= 12 and a!=0 and b!= 0:
  print("MMYY")
elif  b<=31 and a<=12 and a!=0 and b!= 0 :
  print("YYMM")
else :
  print("NA")
inp = input()
fst = int(inp[0:2])
snd = int(inp[2:4])

if(fst!=0 and fst>0 and fst<=12 and snd!=0 and snd>0 and snd<=12):
    print("AMBIGUOUS")
else:
    if(fst!=0 and fst>0 and fst>=12 and snd>0 and snd!=0 and snd<=12):
        print("YYMM")
    elif(fst!=0 and fst>0 and snd>0 and fst<=12 and snd!=0 and snd>=12):
        print("MMYY")
    else:
        print("NA")
str_MY = input()
int_f = int(str_MY[:2])
int_b = int(str_MY[2:])
if (12<int_f and 0<int_b<13) or (int_f ==0 and 0<int_b<13):
    print('YYMM')
elif (12<int_b and 0<int_f<13) or (int_b ==0 and 0<int_f<13):
    print('YYMM')
elif 0<int_b<13 and 0<int_f<13:
    print('AMBIGUOUS')
else:
    print('NA')
s = raw_input()

m = [i for i in xrange(1,13)]

y = [i for i in xrange(1,100)]

f2 = int(s[:2])
l2 = int(s[2:])
if (f2 in m and f2 in y) or (l2 in m and l2 in y):
    print "AMBIGUOUS"
elif f2 in m and l2 in y   :
    print "MMYY"
elif f2 in y and l2 in m:
    print "YYMM"
else:
    print "NA"
num = input()
if int(num[:2]) > 12:
    if int(num[2:]) > 12 or int(num[2:])== 0:
        print('NA')
    else:
        print('YYMM')
else:
    if int(num[2:]) > 12 and int(num[2:])== 0:
        print('MMYY')
    else:
        print('AMBIGUOUS')
S = input()
S1 = int(S[:2])
S2 = int(S[2:])

if S1 == 0 or S2 == 0:
    print('NA')
elif S1 >= 13 and S2 < 13:
    print('YYMM')
elif S1 < 13 and S2 >= 13:
    print('MMYY')
else:
    print('AMBIGUOUS')
n = input()
a = int(n[0:2])
b = int(n[2:])
if a > 12 and b > 12:
  print('NA')
elif a > 12 and b <= 12:
  print('YYMM')
elif a <= 12 and b > 12:
  print('MMYY')
else:
  print('AMBIGUOUS')
x = list(input())

x12 = int(''.join(x[:2]))
x34 = int(''.join(x[2:]))

is_12YYMM = True
is_34YYMM = None
is_12MMYY = None
is_34MMYY = True

if (x12 > 12) or (x12 < 1):
  is_12MMYY = False
else:
  is_12MMYY = True

if (x34 > 12) or (x34 < 1):
  is_34YYMM = False
else:
  is_34YYMM = True

if (is_12YYMM and is_34YYMM) and (is_12MMYY and is_34YYMM):
  print('AMBIGUOUS')
elif (is_12YYMM and is_34YYMM):
  print('YYMM')
elif (is_12MMYY and is_34YYMM):
  print('MMYY')
else:
  print('NA')
S = input()
YYMM = 0
MMYY = 0
start = S[0:2]
end = S[2:4]
tmp1 = int(start)
tmp2 = int(end)
if(tmp1 != 0 and tmp2 <= 12 and tmp2 != 0):
    YYMM = 1
if(tmp2 != 0 and tmp1 <= 12 and tmp1 != 0):
    MMYY = 1
if(YYMM == 1 and MMYY == 1):
    print("AMBIGUOUS")
elif(YYMM == 1):
    print("YYMM")
elif(MMYY == 1):
    print("MMYY")
else:
    print("NA")
#!/usr/bin/env python3

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<=12 and n2<=12:
    print("AMBIGUOUS")
elif n1!=0 or n1<=12:
    print("MMYY")
elif n2!=0 or n2<=12:
    print("YYMM")
else:
    print("errer")
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()
A = int(S[0:2])
B = int(S[2:])

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

print(strFormat)
n = input()
a = int(n[:2])
b = int(n[2:])

if 0 < a <= 12 and  b > 12:
    print('MMYY')
elif a > 12 and 0 < b <= 12:
    print('YYMM')
elif 0 < a <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
S = list(input())
if int(''.join(S[0:2])) == 0 or int(''.join(S[2:4])) == 0:
    print('NA')
elif int(''.join(S[0:2])) > 12 and int(''.join(S[2:4])) > 12:
    print('NA')
elif int(''.join(S[0:2])) <= 12 and int(''.join(S[2:4])) > 12:
    print('MMYY')
elif int(''.join(S[0:2])) > 12 and int(''.join(S[2:4])) <= 12:
    print('YYMM')
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 * s1 + s2) < 12):
  print('YYMM')
elif(0 < (10 * s3 + s4) < 12):
  print('MMYY')
else:
  print('NA')
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    isMM = lambda s: int(s) > 0 and int(s) <= 12
    if   isMM(S[:2]) and int(S[2:]) > 12: print('MMYY')
    elif int(S[:2]) > 12 and isMM(S[2:]): print('YYMM')
    elif isMM(S[:2]) and isMM(S[2:]): print('AMBIGUOUS')
    else: print('NA')

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

if int(s[2:]) > 12: #下2桁
    if int(s[:2]) == 0: #上2桁
        print('NA')
    elif int(s[:2]) > 12:
        print('NA')
    elif int(s[:2]) <= 12:
        print('MMYY')
elif int(s[2:]) <= 12 and int(s[2:]) > 0:
    if int(s[:2]) == 0:
        print('YYMM')
    elif int(s[:2]) <= 12:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    print('NA')
s= str(input())
s1, s2, s3, s4 = [int(i) for i in s]
if (s1 == 0 and 1 <= s2 and s2 <= 9) or (s2 == 1 and 0 <= s2 and s2 <= 2):
    if (s3 == 0 and 1 <= s4 and s4 <= 9) or (s3 == 1 and 0 <= s4 and s4 <= 2):
        print("AMBIGUOUS")
    
    else:
        print("MMYY")
else:
    if (s3 == 0 and 1 <= s4 and s4 <= 9) or (s3 == 1 and 0 <= s4 and s4 <= 2):
        print("YYMM")
    else:
        print("AMBIGUOUS")
s = input()

if 1<=int(s[:2])<=12 and 1<=int(s[2:])<=12:
  print('AMBIGUOUS')
elif 1<=int(s[:2])<=12 and int(s[2:])>12:
  print('MMYY')
elif int(s[:2])>12 and 1<=int(s[2:])<=12:
  print('YYMM')
else:
  print('NA')
def mmyy():
  S=input()
  
  former=S[:2]
  later=S[2:]
  
  if(int(former)>0 and int(former)<13):
    #前半:mm かも
    if(int(later)>0 and int(later)<13):
      print("AMBIGUOUS")
    else:
      print("mmyy")
      
  else:
    if(int(later)>0 and int(later)<13):
      print("yymm")
    else:
      print("NA")

if __name__ =="__main__":
  mmyy()
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":
    print("NA")
  else:
    print("YYMM")
    
elif int(be)<=12:
  if be=="00":
    print("NA")
  else:
    print("MMYY")
  
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 13<=y<=99:
  print('MMYY')
elif 13<=x<=99 and 1<=x<12:
  print('YYMM')
elif 1<=x<=12 and y==0:
  print('MMYY')
elif x==0 and 1<=y<=12:
  print('YYMM')
else:
  print('NA')
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 a<13:
    print('YYMM')
  elif a!= 0 and b<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 = int(input())

f = S // 100
b = S % 100

if 1 <= f and f <= 12:
	if b <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 1 <= b and b <= 12:
		print("YYMM")
	else:
		print("NA")
n=input()
f=n[:2]
l=n[2:]
if f=="00" or l=="00" or (int(f)>12 and int(l)>12):
    print("NA")
elif int(f)>12:
    print("YYMM")
elif int(l)>12:
    print("MMYY")
else:
    print("AMBIGUOUS")
s = input()
sa = int(s[:2])
sb = int(s[3:])

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')
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])
if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif 0 < a <= 12 and b > 12:
    print("MMYY")
elif a > 12 and 0 < b <= 12:
    print("YYMM")
else:
    print("NA")
s=input()
yy = ["%02d" % i for i in range(100)]
mm = ["%02d" % i for i in range(1, 13)]
print(mm)
yymm = s[:2] in yy and s[2:] in mm
mmyy = s[:2] in mm and s[2:] in yy
print(["NA","MMYY","YYMM","AMBIGUOUS"][yymm*2+mmyy])
s = str(input())
top = int(s[:2])
bottom = int(s[2:])

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

if s[:2] == "00" and 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")
z = input()
x = int(z[:2])
y = int(z[2:])

if ( x == 0 and y == 0) or ( x> 12 and y > 12):
      print("NA")
elif (x <= 12):
      if (y<= 12):
            print("AMBIGUOUS")
      else:
            print("MMYY")
else:
      print("YYMM")
S = input()
month_list = ["01","02","03","04","04","05","06","07","08","09","10","11","12"]

if S[0:2] in month_list:
    if S[2:4] in month_list:
        print("AMBIGUOUS")
    elif S[2:4] == "00":
        print("NA")
    else:
        print("MMYY")

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

a = S//100
b = S%100

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

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

first_two=int(''.join(s[:2]))
last_two=int(''.join(s[2:]))

if 1<=first_two<=12 and 1<=last_two<=12:
  print('AMBIGUOUS')
elif 1<=last_two<=12:
  print('YYMM')
elif 13<=last_two and 1<=first_two<=12:
  print('MMYY')
else:
  print('NA')
S = input()

#print(int(S[:2]), int(S[2:]))

if int(S[2:]) == 0 or int(S[:2]) == 0:
    print('NA')
elif int(S[:2]) <= 12:
    print('MMYY')
elif int(S[2:]) <= 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) > 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')
def main():
    s = input()
    up = int(s[0:2])
    lo = int(s[-2:])
    if can_month(up):
        if can_month(lo):
            print('AMBIGUOUS')
        else:
            print('MMYY')

    else:
        if can_month(lo):
            print('YYMM')
        else:
            print('AMBIGUOUS')


def can_month(v):
    if v > 0 and v <= 12:
        return True
    else:
        return False

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

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

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

else:
    print('NA')
#!/usr/bin/env python

S = input()

yy = int(S[0:2])
mm = int(S[2:])

if yy == 0 or mm == 0 :
    print("NA")
    exit(0)

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

if 1 <= start <= 12 and 1 <= end <= 12:
    print("AMBIGUOUS")
elif 1 <= start <= 12 and (end > 12 or end == 0):
    print("MMYY")
elif (start > 12 or end == 0) and 1 <= end <= 12:
    print("YYMM")
else:
    print("NA")
s=list(input())
fst=int(s[0])*10+int(s[1])
scd=int(s[2])*10+int(s[3])
if fst>12 and scd>12:
	print("NA")
elif fst>12 and scd<=12:
	print("YYMM")
elif fst<=12 and scd>12:
	print("MMYY")
else:
	print("AMBIGOUS")
def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13:
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA')
main()
S = input()
f = int(S[:2])
b = int(S[2:])
if f > 12 and 0 < b <= 12:
    print('YYMM')
elif b > 12 and 0 < f <= 12:
    print('MMYY')
elif 0 < f <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
s = input()
s1 = int(s[:2])
s2 = int(s[2:4])

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

if 1 <= x <= 12 and 1 <= y <= 12:
    print("AMBIGUOUS")
elif 1 <= x <= 12 and 1 <= y <= 99:
    print("MMYY")
elif 1 <= y <= 12 and 1 <= x <= 99:
    print("YYMM")
else:
    print("NA")
n=int(input())
m=n%100
y=n//100
if 0<m and m<=12 and y>12:
	print("YYMM")
	
elif 0<y and y<=12 and m>12:
	print("MMYY")
elif 0<y and y<=12 and m<=12:
			print("AMBIGUOUS")
	
		
elif 0<m and m<=12 and y<=12:
	print("AMBIGUOUS")
	
else:
	print("NA")
S = input()
if 0< int(S[0:2]) < 13: #月の可能性
    if 0< int(S[0:2]) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
    
elif 0< int(S[2:5]) < 13: #月の可能性
    print("YYMM")
    
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")
elif c>12 or c==0:
  if b>12 or b==0:
    print("Na")
  elif 1<=b<=12:
    print("MMYY")
else:
  print("AMBIGUOUS")
s=int(input())
n1=s//100
n2=s%100
if 0<n1<=12 and 0<n2<=12:
    print('AMBIGUOUS')
elif 0<n1 and 0<n2<=12:
    print('YYMM')
elif 0<n2 and 0<n1<=12:
    print('MMYY')
else:
    print('NA')
def main():
    S = input()
    if int(S[:2]) > 12 and 12 >= int(S[2:]) > 0:
        print("YYMM")
    elif int(S[2:]) > 12 and 12 >= int(S[:2]) > 0:
        print("MMYY")
    elif 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("NA")


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

    l = int(S[:2])
    r = int(S[2:])

    if l > 12 and r > 12:
        print("NA")
        exit()
    if l == 0 and r == 0:
        print("NA")
        exit()

    if l > 12 or l == 0:
        print("YYMM")
        exit()

    if r > 12 or r == 0:
        print("MMYY")
        exit()

    print("AMBIGUOUS")


main()
s = input()
if "00" in s:
    print("NA")
    exit(0)
ans = ""
s1 = int(s[:2])
s2 = int(s[-2:])
if s1 + s2 >= 26:
    ans = "NA"
elif s1 <= 12 and s2 <= 12:
    ans = "AMBIGUOUS"
elif s1 > 12:
    ans = "YYMM"
else:
    ans = "MMYY"
print(ans)
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:
    print('MMYY')
elif left > 12 >= right > 0:
    print('YYMM')
else:
    print('NA')
S=input()
a,b=int(S[:2]),int(S[2:])
if 0<a<13 and b<13:
    print('AMBIGUOUS')
elif 0<a<13:
    print('MMYY')
elif 0<b<13:
    print('YYMM')
else:
    print('NA')
S = input()

A = S[:2]
B = S[2:]

if int(A) == 0 or int(B) == 0:
    print("NA")
elif int(A) <= 12 and int(B) > 12:
    print("MMYY")
elif int(A) > 12 and int(B) <= 12:
    print("YYMM")
else:
    print("AMBIGUOUS")
n=input()
a=int(n[0:2])
b=int(n[2:4])
if a<13 and b<13:
    print('AMBIGUOUS')
elif a>=1 and a<=12:
    print('MMYY')
elif 1<=b and b<=12:
    print('YYMM')
else:
    print('NA')
S = input()

if int(S[:2]) > 12 and int(S[2:]) == 0:
    print("NA")
elif int(S[2:]) > 12 and int(S[:2]) == 0:
    porint("NA")
elif int(S[2:]) > 12 and int(S[:2]) > 12:
    print("NA")
elif int(S[:2]) == int(S[2:]) == 0:
    print("NA")
elif int(S[:2]) > 12:
    print("YYMM")
elif int(S[2:]) > 12:
    print("MMYY")
else:
    print("AMBIGUOUS")
S = input()

ans = 'NA'
L = int(S[ : 2])
R = int(S[2 :])

if L > 12 and 13 > R > 0:
    ans = 'YYMM'
elif  13 > L > 0 and R > 12:
    ans = 'MMYY'
elif 13 > L > 0 and 13 > R > 0:
    ans = 'AMBIGUOUS'

print(ans)
def main():
    s = list(input())
    s12 = int(s[0]) * 10 + int(s[1]) * 1
    s34 = int(s[2]) * 10 + int(s[3]) * 1
    l = list()
    for i in [s12, s34]:
        if i >= 1 and i <= 12:
            l.append(1)
        else:
            l.append(0)
    if sum(l) == 0:
        print('NA')
    elif sum(l) == 1:
        print('YYMM')
    else:
        print('AMBIGUOUS')

if __name__ == '__main__':
    main()
S = str(input())
front = int(S[:2])
back = int(S[2:])
S_list = list(S)

if front > 12 or front == 0:
    if 0 < back <= 12 :
        print("YYMM")
    else:
        print("NA")
elif front <= 12 and front == 0:
    if 0 < back <= 12: 
        print("AMBIGUOUS")
    else:
        print("MMYY")
s = input()
sa = int(s[:2])
sb = int(s[3:])

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

if 0 < int(s[:2]) <= 12 and 0 < int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif 0 < int(s[:2]) <= 12 and int(s[2:]) >= 12:
    print('MMYY')
elif int(s[:2]) >= 12 > 0 and 0 < int(s[2:]) <= 12:
    print('YYMM')
elif int(s[:2]) == 0 and 0 < int(s[2:]) <= 12:
    print('YYMM')
else:
    print('NA')
s = list(input())
a=int("".join(s[0:2]))
b=int("".join(s[2:4]))
print("NA" if a==0 or b==0 else 
      "NA" if a > 12 and b > 12 else 
      "YYMM" if a > 12 else 
      "MMYY" if b > 12 else 
      "AMBIGUOUS")
s = list(input())
a=int("".join(s[0:2]))
b=int("".join(s[2:4]))
print("NA" if a==0 or b==0 else 
      "NA2" if a > 12 and b > 12 else 
      "YYMM" if a > 12 else 
      "MMYY" if b > 12 else 
      "AMBIGUOUS")
s=int(input())
a=s//100
b=s%100
if a==0 or b==0:
  print("NA")
elif a>=13 and b>=13:
  print("NA")
elif a>=13 and b<=12:
  print("YYMM")
elif a<=12 and b>=13:
  print("MMYY")
else:
  print("AMBIGUOUS")
S = input()
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 <= 12 and b <= 12:
  print('AMBIGUOUS')
elif a <= 12 and b > 12:
  print('MMYY')
elif a > 12 and b <= 12:
  print('YYMM')
S = input()
 
if int(S[:2]) > 13:
  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, b = int(s[:2]), int(s[2:])
if (f == 0 or b == 0): print("NA")
elif (f <= 12 and b <= 12): print("AMBIGUOUS")
elif (f > 12 and b > 12): print("WA")
elif (f > 12): print("YYMM")
elif(b > 12): print("MMYY")
s = input()

l = list(s)

x = int(l[0]+l[1])
y = int(l[2]+l[3])

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

A = int(S[0]) + int(S[1])
B = int(S[2]) + int(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()

a, b = int(s[:2]), int(s[2:])
if 0 < a < 13 and 0 < b < 13:
    print('AMBIGOUS')
elif 0 < a < 13:
    print('MMYY')
elif 0 < b < 13:
    print('YYMM')
else:
    print("NA")
try:
    s1=(input(''))
    if len(s1)!=4:
        raise ValueError
    
    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("AMBIGUOUS")
    else:
        print("NA")
except ValueError:
    print("More than four digits")
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 (0<=int(b)<100) )or ((1<= int(b)<=12) and (0<=int(a)<100)):
        print("AMBIGUOUS")
    else:
        print("NA")
main()