Problem:
 Score : 200 points    Problem Statement You have a digit sequence S of length 4 . You are wondering which of the following formats S is in:   YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order  MMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order   If S is valid in only YYMM format, print YYMM ; if S is valid in only MMYY format, print MMYY ; if S is valid in both formats, print AMBIGUOUS ; if S is valid in neither format, print NA .      Constraints  S is a digit sequence of length 4 .         Input Input is given from Standard Input in the following format:  S       Output Print the specified string: YYMM , MMYY , AMBIGUOUS or NA .        Sample Input 1 1905      Sample Output 1 YYMM  May XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.       Sample Input 2 0112      Sample Output 2 AMBIGUOUS  Both December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.       Sample Input 3 1700      Sample Output 3 NA  Neither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.

Solution (Python):
s = input()
pre = s[0:2]
post = s[2:]

pre = int(pre)
post = int(post)

if (13 > pre) and (pre > 0):
    s_pre = "M"
else:
    s_pre = "NM"

if (13 > post) and (post > 0):
    s_post = "M"
else:
    s_post = "NM"




if s_pre == "M":
    if s_post == "NM":
        ans = "MMYY"
    else:
        ans = "AMBIGUOUS"
else:
    if s_post == "NM":
        ans = "NA"
    else:
        ans = "YYMM"
print(ans)

Solution (Python):
S= input()
u = int(S[:2])
l = int(S[2:])
YYMM = False
MMYY = False
if 1<=l<=12:
    YYMM = True
if 1<=u<=12:
    MMYY = True
if YYMM and MMYY:
    print("AMBIGUOUS")
elif YYMM:
    print("YYMM")
elif MMYY:
    print("MMYY")
else:
    print("NA")

Solution (Python):
S=int(input())

S1 = S // 100
S2 = S % 100

if S1 == 0:
    if S2 == 0 or S2 > 12:
        print('NA')
    else:
        print('YYMM')
elif S1 != 00 and S1 < 13:
    if S2 == 0 or S2 > 12:
        print('MMYY')
    else:
        print('AMBIGUOUS')
else:
    if S2 == 0 or S2 > 12:
        print('NA')
    else:
        print('YYMM')

Solution (Python):
s=input()

yy=int(s[:2])
mm=int(s[2:])

if yy <= 12 and mm <= 12 and yy != 0 and mm != 0:
    print('AMBIGUOUS')
elif mm <= 12 and mm != 0:
    print('YYMM')
elif yy <= 12 and yy != 0:
    print('MMYY')
else:
    print('NA')

Solution (Python):
def mcheck(m):
  if m >= 1 and m <= 12:
    return True
  else:
    return False

S = [int(x) for x in list(input())]
  
A = S[0] * 10 + S[1]
B = S[2] * 10 + S[3]

Acheck = mcheck(A)
Bcheck = mcheck(B)

result = 'NA'
if Acheck and Bcheck:
  result = 'AMBIGUOUS'
elif Acheck == True and Bcheck == False:
  result = 'MMYY'
elif Acheck == False and Bcheck == True:
  result = 'YYMM'
  
print(result)

Solution (Python):
s = input()
left = int(s[:2])
right = int(s[2:])
 
if 1 <= left and left <=12 and 1 <= right and right <= 12:
  print("AMBIGUOUS")
elif 1 <= left and left <= 12:
  print("MMYY")
elif 1 <= right and right <= 12:
  print("YYMM")
else:
  print("NA")

Solution (Python):
s=input()
a=int(s[0])*10+int(s[1])
b=int(s[2])*10+int(s[3])
pp=['NA','MMYY','YYMM','AMBIGUOUS']
c=0
if 1<=a<=12:
  c+=1
if 1<=b<=12:
  c+=2
print(pp[c])

Solution (Python):
S = input()
S1 = int(S[:2])
S2 = int(S[2:])

if S1 == 0:
    if S2 > 0 and S2 <= 12:
        print("YYMM")
    else:
        print("NA")
elif S1 <= 12:
    if S2 > 0 and S2 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if S2==0 or S2 > 12:
        print("NA")
    else:
        print("YYMM")

Solution (Python):
S = input()
S = list(S)

formar = S[0]+S[1]
latter = S[2]+S[3]

if int(formar) > 12 and int(latter) > 12:
    print("NA")
elif int(formar) <= 12 and int(latter) <= 12:
    if formar == "00" and not latter == "00":
        print("YYMM")
    elif latter == "00" and not formar == "00":
        print("MMYY")
    elif formar == "00" and latter == "00":
        print("NA")
    else:
        print("AMBIGUOUS")
elif int(formar) > 12:
    if latter == "00":
        print("NA")
    else:
        print("YYMM")
else:
    if formar == "00":
        print("NA")
    else:
        print("MMYY")

Solution (Python):
import re
list = re.split('(..)', input())[1::2]
a = int(list[0])
b = int(list[1])
if a>0 and a<=12 and b>=1 and b<=12:
    print("AMBIGUOUS")
elif a>12 and b>0 and b<=12:
    print("YYMM")
elif a==0 and b>0 and b<=12:
    print("YYMM")
elif a<=12 and a>0 and b>12:
    print("MMYY")
elif a<=12 and a>0 and b==0:
    print("MMYY")
else:
    print("NA")

Solution (Python):
S = input()
le = int(S[0:2])
ri = int(S[2:4])
if (le == 0 and ri == 0) or (le == 0 and ri > 12) or (le > 12 and ri == 0) or (le>12 and ri>12):
  print("NA")
elif 0 < le <= 12 and 0 < ri <= 12:
  print("AMBIGUOUS")
elif 0 < le <= 12 and ( ri == 0 or ri >12 ):
  print("MMYY")
elif 0 < ri <= 12 and ( le == 0 or le >12 ):
  print("YYMM")

Solution (Python):
s = list(input())

if (int(s[0])==0 and 1<=int(s[1])<=9) or (int(s[0])==1 and 0<=int(s[1])<=2):
    if(int(s[2])==0 and 1<=int(s[3])<=9) or (int(s[2])==1 and 0<=int(s[3])<=2):
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif(int(s[2])==0 and 1<=int(s[3])<=9) or (int(s[2])==1 and 0<=int(s[3])<=2):
    print('YYMM')
else:
    print('NA')

Solution (Python):
f = "YYMM"
s = "MMYY"


st = input()

mm = int(st[:2])
yy = int(st[2:])



if (mm > 0 and mm < 13) and (yy > 0 and yy < 13):
    print("AMBIGUOUS")

elif (yy > 0 and yy < 13) and ( mm < 1 or mm > 12):
    print(f)
    
elif (yy < 1 or yy > 12) and ( mm > 0 and mm < 13):
    print(s)
else:
    print("NA")

Solution (Python):
X1 = list(map(str, input().split()))

X2 = X1[0]

mae = int(X2[0:2])
ushiro = int(X2[2:4])

if(1 <= mae <= 12 and 1 <= ushiro <= 12):
    print("AMBIGUOUS")
elif(1 <= mae <= 12 and (ushiro < 1 or 12 < ushiro)):
    print("MMYY")
elif((mae < 1 or 12 < mae) and 1 <= ushiro <= 12):
    print("YYMM")
elif((mae < 1 or 12 < mae) and (ushiro < 1 or 12 < ushiro)):
    print("NA")

Solution (Python):
s = input()
u = int(s[0] + s[1])
l = int(s[2] + s[3])

if l == 0 or u == 0:
    if 0 < l and l < 13:
        print('YYMM')

    elif 0 < u and u < 13:
        print("MMYY")
    else:
        print('NA')

elif 0 < l and l < 13:

    if 0 < u and u < 13:
        print('AMBIGUOUS')
    else:
        print("YYMM")

elif 0 < u and u < 13:
    print("MMYY")
else:
    print('NA')

Solution (Python):
s = input()

f2 = int(s[:2])
b2 = int(s[2:])

if ((f2 >= 13 or f2 == 0) and (b2 >= 13 or b2 == 0)):
    print("NA")
elif ((f2 >= 1 and f2 <= 12) and (b2 >= 1 and b2 <= 12)):
    print("AMBIGUOUS")
elif (f2 >= 13 or f2 == 0):
    print("YYMM")
elif (f2 >= 1 and f2 <= 12):
    print("MMYY")

Solution (Python):
s = input()
if (s[0] == "0" and s[1] != "0") or (s[0] == "1" and s[1] == "0") or (s[0] == "1" and s[1] == "1") or (s[0] == "1" and s[1] == "2"):
  if (s[2] == "0" and s[3] != "0") or (s[2] == "1" and s[3] == "0") or (s[2] == "1" and s[3] == "1") or (s[2] == "1" and s[3] == "2"):
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if (s[2] == "0" and s[3] != "0") or (s[2] == "1" and s[3] == "0") or (s[2] == "1" and s[3] == "1") or (s[2] == "1" and s[3] == "2"):
    print("YYMM")
  else:
    print("NA")

Solution (Python):
S=input()
aa=int(S[0])
a=int(S[1])
bb=int(S[2])
b=int(S[3])
a=a+aa*10
b=b+bb*10
if 0<a<13 and 0<b<13:
  print("AMBIGUOUS")
elif a==0 or a>12:
  if b==0 or b>12:
    print("NA")
  else:
    print("YYMM")
elif b==0 or b>12:
  if a==0 or a>12:
    print("NA")
  else:
    print("MMYY")

Solution (Python):
s = raw_input()

x = int(s[0:2])
y = int(s[2:])

yymm = 0
mmyy = 0

if y > 0 and y <= 12:
    yymm = 1

if x > 0 and x <= 12:
    mmyy = 1

if mmyy and yymm:
    print "AMBIGUOUS"
elif mmyy:
    print "MMYY"
elif yymm:
    print "YYMM"
else:
    print "NA"

Solution (Python):
s = input()
is_yy = lambda x: 0 <= int(x) <= 99
is_mm = lambda x: 1 <= int(x) <= 12

yymm = False
mmyy = False

a = is_yy(s[:2])
b = is_mm(s[2:])

if a and b:
    yymm = True

a = is_mm(s[:2])
b = is_yy(s[2:])

if a and b:
    mmyy = True

if yymm and mmyy:
    print('AMBIGUOUS')
elif yymm:
    print('YYMM')
elif mmyy:
    print('MMYY')
else:
    print('NA')

Solution (Python):
S = input()
a = int(S[:2])
b = int(S[2:])


f1 = 1 <= b <= 12


f2 = 1 <= a <= 12

if f1 and f2:
    print('AMBIGUOUS')
elif f1:
    print('YYMM')
elif f2:
    print('MMYY')
else:
    print('NA')

Solution (Python):
import datetime
S = input()

def YYMM(S):
	try:
		datetime.datetime.strptime(S,"%y%m")
		return True
	except ValueError:
		return False

def MMYY(S):
	try:
		datetime.datetime.strptime(S,"%m%y")
		return True
	except ValueError:
		return False

YM = YYMM(S)
MY = MMYY(S)

if YM and MY:
	print("AMBIGUOUS")
elif YM:
	print("YYMM")
elif MY:
	print("MMYY")
else:
	print("NA")

Solution (Python):
S = list(input())

left =  ''.join(S[0:2])
right = ''.join(S[2:4])


left_flag = 0
right_flag = 0
if int(left) <= 12 and left != '00':
    left_flag = 1

if int(right) <= 12 and right != '00':
    right_flag = 1


if left_flag == 1 and right_flag == 0:
    print('MMYY')
elif left_flag == 1 and right_flag == 1:
    print('AMBIGUOUS')
elif left_flag == 0 and right_flag == 1:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = list(input())
S_1 = int("".join(S[0:2]))
S_2 = int("".join(S[2:4]))



if 1 <= S_1 and S_1 <= 12 and 1 <= S_2 and S_2 <= 12:
    print("AMBIGUOUS")
elif 1 <= S_1 and S_1 <= 12:
    print("MMYY")
elif 1 <= S_2 and S_2 <= 12:
    print("YYMM")
else:
    print("NA")

Solution (Python):
s=input()
ans=''
if 0<int(s[:2])<=12 and 0<int(s[2:])<=12:
  ans='AMBIGUOUS'
elif 0<int(s[2:])<=12:
  if int(s[:2])>12 or int(s[:2])==0:
    ans='YYMM'
elif 0<int(s[:2])<=12:
  if int(s[2:])>12 or int(s[2:])==0:
    ans='MMYY'
else:
  ans='NA'
print(ans)

Solution (Python):
S = input()

mae = int(S[0]+S[1])
ato = int(S[2]+S[3])

if 0 < mae and mae < 13 and 0 < ato and ato < 13:
    print('AMBIGUOUS')
elif mae == 0 or mae > 12:
    if 0 < ato and ato < 13:
        print('YYMM')
    else:
        print('NA')
elif ato == 0 or ato > 12:
    if 0 < mae and mae < 13:
        print('MMYY')
    else:
        print('NA')

Solution (Python):


def if_YYMM(text):
    yy = int(text[0:2])
    mm = int(text[2:4])
    
    if mm < 1 or mm > 12:
        return False
    
    return True

def if_MMYY(text):
    mm = int(text[0:2])
    yy = int(text[2:4])
    
    if mm < 1 or mm > 12:
        return False
    
    return True

text = input()

mmyy = if_MMYY(text)
yymm = if_YYMM(text)

if mmyy & yymm:
    print("AMBIGUOUS")
elif mmyy:
    print("MMYY")
elif yymm:
    print("YYMM")
else:
    print("NA")

Solution (Python):
inputdata = input()
up = int(inputdata[0:2])
down = int(inputdata[2:4])
if 0 < up <= 12:
  if 0 < down <=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < down <= 12:
    print("YYMM")
  else:
    print("NA")

Solution (Python):
S = input()

x = int(S[:2])
y = int(S[2:])

flg1 = False
flg2 = False

if x >= 1 and x <= 12:
    flg1 = True

if y >= 1 and y <= 12:
    flg2 = True

if flg1 == True and flg2 == True:
    print('AMBIGUOUS')

elif flg1 == False and flg2 == True:
    print('YYMM')

elif flg1 == True and flg2 == False:
    print('MMYY')

else:
    print('NA')

Solution (Python):
s=list(input())
s=list(map(int,s))
t=10*s[0]+s[1]
k=10*s[2]+s[3]
if 1<=t<=12:
  if 1<=k<=12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif 1<=k<=12:
  print("YYMM")
else:
  print("NA")

Solution (Python):



s = input().rstrip()

front = s[:2]
back = s[2:4]

isyymm = True if (0 <= int(front) <= 99 and 1 <= int(back) <= 12) else False
ismmyy = True if (0 <= int(back) <= 99 and 1 <= int(front) <= 12) else False

if isyymm and (not ismmyy):
    print("YYMM")
elif (not isyymm) and ismmyy:
    print("MMYY")
elif isyymm and ismmyy:
    print("AMBIGUOUS")
else:
    print("NA")

Solution (Python):
def main():
    S = input()
    first = int(S[:2])
    latter = int(S[2:])
    yymm = True
    mmyy = True
    if first > 12 or first == 0:
        mmyy = False
    if latter > 12 or latter == 0:
        yymm = False
    if mmyy and yymm:
        print("AMBIGUOUS")
    elif mmyy:
        print("MMYY")
    elif yymm:
        print("YYMM")
    else:
        print("NA")
main()

Solution (Python):




S = input()

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

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

Solution (Python):
def MMcheck(MM):
    if 1 <= MM and MM <= 12:
        return 1
    else:
        return 0
S = input()
s = list(S)


mae = int("".join(s[0:2]))

countmae = MMcheck(mae)

ushiro = int("".join(s[2:4]))

countushiro = MMcheck(ushiro)

if countmae == 1 and countushiro == 1:
    print("AMBIGUOUS")
elif countmae == 0 and countushiro == 1:
    print("YYMM")
elif countmae == 1 and countushiro == 0:
    print("MMYY")
else:
    print("NA")

Solution (Python):
def m(ss):
    if ss > 0 and ss <= 12:
        return 1
    return 0

s = list(input())
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if m(s1) and m(s2):
    print("AMBIGUOUS")
elif m(s1) and not(m(s2)):
    print("MMYY")
elif not(m(s1)) and m(s2):
    print("YYMM")
else:
    print("NA")

Solution (Python):
s = input()
a, b = int(s[:2]), int(s[2:])
if a >= 13 and a <= 99 or a == 00:
    if b >= 1 and b <= 12:
        print("YYMM")
    else:
        print("NA")
else:
    if b >= 1 and b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")

Solution (Python):
s = input()
m2 = int(s[0] + s[1])
u2 = int(s[2] + s[3])

YM = False
MY = False

if m2 < 13 and m2 != 0:
  MY = True
if u2 < 13 and u2 != 0:
  YM = True
if (m2 == 0 and u2 >12) or (u2 == 0 and m2 >12) or (m2 == 0 and u2 == 0):
  YM = False
  MY = False
  
if YM == False and MY == True:
  print('MMYY')
elif MY == False and YM == True:
  print('YYMM')
elif YM == MY == False:
  print('NA')
else:
  print('AMBIGUOUS')

Solution (Python):
s = input()
if 1<=int(s[:2]) <= 12 and 1<=int(s[2:]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(s[:2]) <= 12:
    print('MMYY')
elif 1 <= int(s[2:]) <= 12:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()
LEFT= int(S[:2])
RIGHT = int(S[2:])

left_m = False
right_m = False

if 1 <= LEFT <= 12:
    left_m = True
    
if 1<= RIGHT <= 12:
    right_m = True

if left_m == True and right_m == True:
    print('AMBIGUOUS')
elif left_m == True and right_m == False:
    print('MMYY')
elif left_m == False and right_m == True:
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()
a = int(S[0:2])
b = int(S[2:4])
ans = ''

if 1 <= a <= 12 and 1 <= b <= 12:
    ans = 'AMBIGUOUS'
elif 1 <= b <= 12:
    ans = 'YYMM'
elif 1 <= a <= 12:
    ans = 'MMYY'
else:
    ans = 'NA'

print(ans)

Solution (Python):
s = input()

p1 = s[0:2]
p2 = s[2:4]

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

if (p1 not in m and p2 in m):
	print("YYMM")
elif (p1 in m and p2 in m):
	print("AMBIGUOUS")
elif (p1 not in m and p2 not in m):
	print("NA")
else:
	print("MMYY")

Solution (Python):
S = input()

s1 = int(S[:2])
s2 = int(S[2:])

def is_month(ss):
    if ss > 0 and ss <= 12:
        return True
    else:
        return False

if is_month(s1) and is_month(s2):
    print('AMBIGUOUS')
elif is_month(s1) and not is_month(s2):
    print('MMYY')
elif is_month(s2) and not is_month(s1):
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = int(input())

simo = S%100
kami = S//100

if( 1 <= kami <= 12 and 1 <= simo <= 12 ):
  print('AMBIGUOUS')
elif( 1 <= kami <= 12 and not(1 <= simo <= 12) ):
  print('MMYY')
elif( not(1 <= kami <= 12) and 1 <= simo <= 12 ):
  print('YYMM')
else:
  print('NA')

Solution (Python):
a = input()
q, mod =divmod(int(a), 100)
if q == 0 :
  if mod < 13 and mod != 0:
    print("YYMM")
  else : print("NA")
elif mod == 0 :
  if q < 13 and q != 0:
    print("MMYY")
  else : print("NA")
elif q < 13 :
  if mod < 13 :
    print("AMBIGUOUS")
  else : print("MMYY")
else:
  if mod < 13 :
    print("YYMM")
  else : print("NA")

Solution (Python):


s = input()


before = int(s[0:2])
after = int(s[2:4])

before_year = False
after_year = False
before_m = False
after_m = False

if before > 12:
    before_year = True
else: before_m = True

if after > 12:
    after_year = True
else: after_m = True

if before==0 and after==0:
    print('NA')
elif before ==0 and after_m==True:
    print('YYMM')
elif after == 0 and before_m==True:
    print('MMYY')
elif before==0 or after==0:
    print('NA')
elif before_year==True and after_year==True:
    print('NA')
elif before_m==True and after_m==True:
    print('AMBIGUOUS')
elif before_year==True and after_m==True:
    print('YYMM')
elif before_m==True and after_year==True:
    print('MMYY')
else:
    print('NA')

Solution (Python):
nazo=int(input())
b=nazo%100
a=int(nazo/100)

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

Solution (Python):
S=input()
if '01'<=S[0:2]<='12':
    MMYY=True
else:
    MMYY=False
if '01'<=S[2:4]<='12':
    YYMM=True
else:
    YYMM=False
if MMYY and YYMM:
    print('AMBIGUOUS')
elif MMYY and not YYMM:
    print('MMYY')
elif not MMYY and YYMM:
    print('YYMM')
else:
    print('NA')

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

Solution (Python):
s = input()
a = int(s[0:2])
b = int(s[2:4])

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

Solution (Python):
import datetime as dt
S = input()
pre = int(S[0:2])
aft = int(S[2:4])


try:
    dt.date(int(pre), int(aft), 1)
    flg_yymm = 1
except:
    if int(pre) == 0 and int(aft) >= 1 and int(aft) <= 12:
        flg_yymm = 1
    else:
        flg_yymm = 0

try:
    dt.date(int(aft), int(pre), 1)
    flg_mmyy = 1
except:
    if int(aft) == 0 and int(pre) >= 1 and int(pre) <= 12:
        flg_mmyy = 1
    else:
        flg_mmyy = 0

if flg_yymm == 1 and flg_mmyy == 1:
    print("AMBIGUOUS")
elif flg_yymm == 1 and flg_mmyy == 0:
    print("YYMM")
elif flg_yymm == 0 and flg_mmyy == 1:
    print("MMYY")
else:
    print("NA")

Solution (Python):
S = input()

if  '01' <= S[:2] <= '12' and '01' <= S[2:] <= '12':
    print('AMBIGUOUS')
elif '01' <= S[:2] <= '12':
    print('MMYY')
elif '01' <= S[2:] <= '12':
    print('YYMM')
else:
    print('NA')

Solution (Python):
S = input()

former = S[0:2]
latter = S[2:4]

is_former_month = False
is_latter_month = False
if 1 <= int(former) <= 12:
    is_former_month = True
if 1 <= int(latter) <= 12:
    is_latter_month = True

if is_former_month and is_latter_month:
    print("AMBIGUOUS")
elif is_former_month:
    print("MMYY")
elif is_latter_month:
    print("YYMM")
else:
    print("NA")

Solution (Python):
c=input()
a=int(c[:2])
b=int(c[2:])
if a in range(1, 13):
	if b in range(1, 13):
		s="AMBIGUOUS"
	else:
		s="MMYY"
elif b in range(1, 13):
	s="YYMM"
else:
	s="NA"
print(s)

Solution (Python):
import re
S = re.split("(..)", input())[1::2]
S[0] = int(S[0])
S[1] = int(S[1])

if 0 < S[0] <= 12:
    if 0 < S[1] <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 0 < S[1] <= 12:
    print("YYMM")
else:
    print("NA")

Solution (Python):
a = int(input())
b = a%100
c = a//100
if 0<b and b<13 and 0<c and c<13:
    print('AMBIGUOUS')
elif 0<b and b<13:
    print('YYMM')
elif 0<c and c<13:
    print('MMYY')
else:
    print('NA')

Solution (Python):
import sys
s = int(input())
a = s //100
b = s % 100
mmyy = 0
yymm = 0

if 1<=a <= 12:
    if 1<=b <= 12:
         yymm = 1
         mmyy = 1
    else:
        mmyy = 1
elif 0 <= a <= 99:
    if 1<=b <= 12:
         yymm = 1

if mmyy == 1 and yymm == 1:
    print("AMBIGUOUS")
elif mmyy == 1:
    print("MMYY")
elif yymm == 1:
    print("YYMM")
else:
    print("NA")

Solution (Python):
S = input()
mae = int(S[0:2])
ato = int(S[2:4])
mM = 0
aM = 0
if 1<=mae<=12:
    mM = 1
if 1<=ato<=12:
    aM = 1
if mM + aM == 2:
    print('AMBIGUOUS')
elif mM + aM == 0:
    print('NA')
elif mM == 1:
    print('MMYY')
else:
    print('YYMM')

Solution (Python):
s = input()

ue = int(s[0]+s[1])
sita = int(s[2]+s[3])

if ue == 0 and sita == 0:
    print('NA')
elif ue == 0 and sita > 0 and sita <= 12:
    print('YYMM')
elif sita == 0 and ue > 0 and ue <= 12:
    print('MMYY')
elif sita > 0 and sita <= 12 and ue > 0 and ue <= 12:
    print('AMBIGUOUS')
elif sita > 0 and sita <= 12 and ue > 12:
    print('YYMM')
elif ue > 0 and ue <= 12 and sita > 12:
    print('MMYY')
elif ue > 12 and sita > 12:
    print('NA')
else:
    print('NA')

Solution (Python):
S = input()
ff = S[:2]
bb = S[2:]

if (int(ff) > 12 or int(ff) <= 0) and (int(bb) > 12 or int(bb) <= 0):
	print('NA')
elif (int(ff) <= 12 and int(ff) > 0) and (int(bb) <= 12 and int(bb) > 0):
	print('AMBIGUOUS')
elif (int(ff) > 12 or int(ff) <= 0) and (int(bb) <= 12 and int(bb) > 0):
	print('YYMM')
else:
	print('MMYY')

Solution (Python):
S = input()

if 1<= int(S[:2]) <= 12:
    if 1<= int(S[2:4]) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<= int(S[2:4]) <= 12:
        print('YYMM')
    else:
        print('NA')

Solution (Python):
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")

Solution (Python):
D = input()
a, b = [int(D[:2]), int(D[2:])]
if (a > 12 or a==0) and b != 0 and b <= 12:
  print('YYMM')
elif a != 0 and a <= 12 and (b > 12 or b == 0):
  print('MMYY')
elif a != 0  and a <= 12 and b != 0 and b <= 12:
  print('AMBIGUOUS')
else:
  print('NA')

Solution (Python):
input_str = input()
zenhan = int(input_str[:2])
kouhan = int(input_str[2:])

if zenhan > 12:
  if kouhan > 12 :
    print('NA')
  elif kouhan == 0:
    print('NA')
  else:
    print('YYMM')
elif zenhan == 0:
  if kouhan > 12 :
    print('NA')
  elif kouhan == 0:
    print('NA')
  else:
    print('YYMM')
else:
  if kouhan >= 1:
    if kouhan <= 12:
      print('AMBIGUOUS')
    else:
      print('MMYY')
  else:
    print('MMYY')

Solution (Python):
s = input()

s1 = s[0:2]
s2 = s[2:4]

yl = ["{:02d}".format(i) for i in range(100)]
ml = ["{:02d}".format(i+1) for i in range(12)]

if (s1 in yl and s2 in ml) and (s1 in ml and s2 in yl):
    print('AMBIGUOUS')
elif (s1 not in yl or s2 not in ml) and (s1 not in ml or s2 not in yl):
    print('NA')
elif (s1 in yl and s2 in ml) ^ (s2 not in yl and s1 not in ml):
    print('YYMM')
elif (s2 in yl and s1 in ml) ^ (s1 not in yl and s2 not in ml):
    print('MMYY')

Solution (Python):
s = input()
f = int(s[:2])
b = int(s[2:])

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

Solution (Python):
a,b,c,d=input()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
if 1<=10*a+b<=12 and 1<=10*c+d<=12:
  print("AMBIGUOUS")
elif 1<=10*a+b<=12 and (10*c+d==0 or 10*c+d>=13):
  print("MMYY")
elif (10*a+b==0 or 10*a+b>=13) and 1<=10*c+d<=12:
  print("YYMM")
else:
  print("NA")

Solution (Python):
s = input()
b1 = False
b2 = False

if s[0] == '1':
    b1 = s[1] <= '2'
elif s[0] == '0':
    b1 = s[1] != '0'

if s[2] == '1':
    b2 = s[3] <= '2'
elif s[2] == '0':
    b2 = s[3] != '0'

if b1:
    print("AMBIGUOUS" if b2 else "MMYY")
else:
    print("YYMM" if b2 else "NA")

Solution (Python):
import sys
input = sys.stdin.readline

S = input().rstrip()
l = [0]*2
y = S[:2]
m = S[2:]
l[0] = 0 if "01" <= y <= "12" else 1
l[1] = 1 if "01" <= m <= "12" else 0

if l[0] == 0 and l[1] == 1:
  print("AMBIGUOUS")
elif l[0] == 1 and l[1] == 1:
  print("YYMM")
elif l[0] == 0 and l[1] == 0:
  print("MMYY")  
else:
  print("NA")

Solution (Python):
S=int(input())
S1=S%100
S2=int(S/100)
if S1<=12 and S1!=0 and S2 <=12 and S2!=0:
    ans='AMBIGUOUS'
elif S1<=12 and S1!=0:
    ans='YYMM'
elif S2 <=12 and S2!=0:
    ans='MMYY'
else:
    ans='NA'
print(ans)

Solution (Python):
s = int(input())
h = s//100
l = s%100


def check_month(i):
    if i <= 12 and i >= 1:
        return True
    else:
        return False

def check_year(i):
    return True
    
    
    
    

ym = check_year(h) and check_month(l)
my = check_month(h) and check_year(l)

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

Solution (Python):
S = input()
upper = int(S[:2])
lower = int(S[2:])
if 1 <= upper <= 12:
  if 1 <= lower <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= lower <= 12:
    print('YYMM')
  else:
    print('NA')

Solution (Python):
s=list(map(int,list(input())))

first=10*s[0]+s[1]
second=10*s[2]+s[3]



if (13<=first or first ==0) and (13<=second or second ==0):
    print("NA")

elif 1 <= first <= 12 and 1 <= second <= 12:
    print("AMBIGUOUS")

elif 1 <= first <= 12 and (second >= 13 or second==0):
    print("MMYY")
elif 1 <= second <= 12 and (first >= 13 or first==0):
    print("YYMM")

Solution (Python):

S=input()

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

if(f==0 and l==0):
	print("NA")
	exit()
if(f==0 and l<=12):
	print("YYMM")
	exit()
if(f<=12 and l==0):
	print("MMYY")
	exit()
if(f==0 and l>12):
	print("NA")
	exit()
if(f>12 and l==0):
	print("NA")
	exit()


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

Solution (Python):
S=str(input())

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



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")

Solution (Python):
S = list(input())
first = int("".join(S[:2]))
last = int("".join(S[2:]))
yymm = False
mmyy = False
if first > 0 and first < 13:
  mmyy = True
if last > 0 and last < 13:
  yymm = True
if yymm and mmyy:
  print("AMBIGUOUS")
elif yymm:
  print("YYMM")
elif mmyy:
  print("MMYY")
else:
  print("NA")

Solution (Python):
S = input()
if S[:2] == "00" and S[2:] == "00":
    print('NA')
elif S[:2] == "00" and int(S[2:]) > 12:
    print('NA')
elif int(S[:2]) > 12 and S[2:] == "00":
    print('NA')
elif S[:2] == "00" and int(S[2:]) <= 12:
    print('YYMM')
elif int(S[:2]) <= 12 and S[2:] == "00":
    print('MMYY')
elif int(S[:2]) > 12 and int(S[2:]) > 12:
    print('NA')
elif int(S[:2]) <= 12 and int(S[2:]) <= 12:
    print("AMBIGUOUS")
elif int(S[:2]) <= 12:
    print("MMYY")
else:
    print('YYMM')

Solution (Python):
import sys
input = sys.stdin.readline

S = input().rstrip()
l = [0]*2
y = S[:2]
m = S[2:]
l[0] = 0 if "01" <= y <= "12" else 1
l[1] = 1 if "01" <= m <= "12" else 0

if l[0] == 0 and l[1] == 1:
  print("AMBIGUOUS")
elif l[0] == 1 and l[1] == 1:
  print("YYMM")
elif l[0] == 0 and l[1] == 0:
  print("MMYY")  
else:
  print("NA")

Solution (Python):
letters = list(input())
flg = ['NOSENCE', 'NOSENCE']
if int(''.join(letters[0:2])) >= 1 and int(''.join(letters[0:2])) <= 12:
  flg[0] = 'MM'
if int(''.join(letters[2:4])) >= 1 and int(''.join(letters[2:4])) <= 12:
  flg[1] = 'MM'

if flg[0] == 'MM' and flg[1] == 'MM':
  answer = 'AMBIGUOUS'
elif flg[0] == 'MM':
  answer = 'MMYY'
elif flg[1] == 'MM':
  answer = 'YYMM'
else:
  answer = 'NA'

print(answer)

Solution (Python):
s = int(input())

flag1 =  0< s//100 <= 12
flag2 =  0< s%100 <= 12

ans = ""

if flag1 and flag2:
    ans = "AMBIGUOUS"
elif not flag1 and flag2:
    ans = "YYMM"
elif flag1 and not flag2:
    ans = "MMYY"
else:
    ans = "NA"

if s/100==0 and flag2:
    ans = "YYMM"
if s%100==0 and flag1:
    ans = "MMYY"

print(ans)

Solution (Python):
s=input().rstrip()
if int(s[0]+s[1])>=1 and int(s[0]+s[1])<=12  and int(s[2]+s[3])>=1 and int(s[2]+s[3])<=12:
    print('AMBIGUOUS')
elif  int(s[0]+s[1])>=1 and int(s[0]+s[1])<=12 and (int(s[2]+s[3])>12 or int(s[2]+s[3])<1):
    print('MMYY')
elif (int(s[0]+s[1])>12 or int(s[0]+s[1])<1) and int(s[2]+s[3])>=1 and int(s[2]+s[3])<=12:
    print('YYMM')
else:
    
    
    
    print('NA')

Solution (Python):
S = int(input())
s12 = S // 100
s34 = S % 100

if s34 >=1 and s34 <= 12:
    yymm = True
else:
    yymm = False

if s12 >=1 and s12 <= 12:
    mmyy = True
else:
    mmyy = False

if yymm and mmyy:
    ans = 'AMBIGUOUS'
elif yymm:
    ans = 'YYMM'
elif mmyy:
    ans = 'MMYY'
else:
    ans = 'NA'

print(ans)

Solution (Python):
S = input()

two_f = int(S[:2])
two_b = int(S[2:])

MMYY_flag = 0
YYMM_flag = 0

if 1 <= two_f <= 12:
    MMYY_flag = 1
if 1 <= two_b <= 12:
    YYMM_flag = 1

if MMYY_flag == 1 and YYMM_flag == 1:
    print('AMBIGUOUS')
elif MMYY_flag == 1:
    print('MMYY')
elif YYMM_flag == 1:
    print('YYMM')
else:
    print('NA')

Solution (Python):
s = int(input())
l = s // 100
r = s % 100
def mm(l):
  return 0 < l < 13
if mm(l) and mm(r):
  print("AMBIGUOUS")
elif mm(l):
  print("MMYY")
elif mm(r):
  print("YYMM")
else:
  print("NA")

Solution (Python):
s = input()
zenhan = int(s[0:2])
kouhan = int(s[2:])

if zenhan > 12 or zenhan==0:
    if kouhan > 12 or kouhan==0:
        print("NA")
    else:
        print("YYMM")
else:
    if kouhan > 12 or kouhan==0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Solution (Python):
S = input()

Left  = int(S[0:2])
Right = int(S[2:4])


if   0 < Left <= 12 and 0 < Right <= 12:
	print("AMBIGUOUS")
elif 0 < Left <= 12 and (Right >= 12 or Right == 0):
	print("MMYY")
elif (Left >= 12 or Left == 0) and 0 < Right <= 12:
	print("YYMM")
else:
	print("NA")

Solution (Python):



S = list(input())

S_int =list(map(int,S))

FIRST = S_int[0]*10+S_int[1]
SECOND = S_int[2]*10+S_int[3]

flag1 = 0
flag2 = 0

if FIRST>0 and  FIRST<=12:
    flag1 = 1
if SECOND>0 and SECOND<=12:
    flag2 = 1

if flag1 == 0 and flag2 == 0:
    print("NA")
    
elif flag1 == 0 and flag2 == 1:
    print("YYMM")
elif flag1 == 1 and flag2 == 0:
    print("MMYY")
elif flag1 == 1 and flag2 == 1:
    print("AMBIGUOUS")

Solution (Python):
s=list(input())

x=int(''.join(s[0:2]))
y=int(''.join(s[2:4]))

if 1<=x<=12 and 1<=y<=12:
    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")

Solution (Python):
s = input()
l = s[0:2]
r = s[2:]
a = int(l)
b = int(r)
if (0 == a or a>12 )and (b >0 and b <13):
    print('YYMM')
elif (a>0 and a<13) and (b ==0 or b>12):
    print('MMYY')
elif (a>0 and a<13) and (b>0 and b <13):
    print('AMBIGUOUS')
else:
    print('NA')

Solution (Python):



import sys


def main():
    S = input()
    AA = int(S[:2])
    BB = int(S[2:])

    ay = is_year(AA)
    am = is_month(AA)
    by = is_year(BB)
    bm = is_month(BB)

    ans = "Error"
    if (ay and bm) == True and (by and am) == False:
        ans = "YYMM"
    elif (ay and bm) == False and (by and am) == True:
        ans = "MMYY"
    elif (ay and bm) == True and (by and am) == True:
        ans = "AMBIGUOUS"
    else:
        ans = "NA"

    print(ans)


def is_year(num):
    return True


def is_month(num):
    ret = False
    if 1 <= num <= 12:
        ret = True

    return ret


if __name__ == "__main__":
    main()