Harryxun/stf_run huggingface dataset:
A, B = map(int,input().split())

def f(n):
    ret=[]
    for i in range(1,49):
        a = 2**i
        b = (n+a//2)//a
        if a>(n+a//2):
            break
        c = (b-1)*(2**(i-1)) + min((n+a//2)-a*b+1, a//2)
        ret.append(c)
    return ret

if A==0:
    y = f(B)
if A>0:
    l1 = f(B)
    l2 = f(A-1)
    l2 += [0]*(len(l1)-len(l2))
    l3 = []
    for i in range(len(l1)):
        l3.append((l1[i]-l2[i])%2)

ans = 0

for i in range(len(l3)):
    ans += (2**i)*l3[i]

print(ans)

### FIXED CODE ###

A, B = map(int,input().split())

def f(n):
    ret=[]
    for i in range(1,49):
        a = 2**i
        b = (n+a//2)//a
        if a>(n+a//2):
            break
        c = (b-1)*(2**(i-1)) + min((n+a//2)-a*b+1, a//2)
        ret.append(c)
    return ret

l1 = f(B)
l2 = f(A-1) if A>0 else []
l2 += [0]*(len(l1)-len(l2))
l3 = []
for i in range(len(l1)):
    l3.append((l1[i]-l2[i])%2)

ans = 0

for i in range(len(l3)):
    ans += (2**i)*l3[i]

print(ans)
K,S=map(int,input().split())
cnt=0
K+=1
for i in range(K):
  for j in range(K):
    k=S-(i+j)
    if (S>=0) and (S<=K)
      cnt+=1
print(cnt)


### FIXED CODE ###

K,S=map(int,input().split())
cnt=0

for i in range(K+1):
  for j in range(K+1):
    k=S-(i+j)
    if (k>=0) and (k<=K):
      cnt+=1
print(cnt)
from functools import reduce
import numpy as np


def print_result(num):
    print(num%(pow(10,9)+7))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

A = np.array(sorted(A, key=abs, reverse=True))
num_negative = np.count_nonzero(A<0)
if N == num_negative:
    if K % 2 == 0:
        print_result(np.prod(A[:K]))
    else:
        print_result(np.prod(A[-K:]))
elif np.count_nonzero(A[:K]<0) % 2 == 0:
    print_result(np.prod(A[:K]))
else:
    for a in A[K:]:
        if a >= 0:
            last = a
    print_result(np.prod(A[:K-1])*last)


### FIXED CODE ###

from functools import reduce
import numpy as np

mod=10**9+7

def mat(list):
    return reduce(lambda a,b: a*b%mod, list)


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = np.array(sorted(A, key=abs, reverse=True))
A_pn = A < 0
if N == np.count_nonzero(A_pn):
    if K % 2 == 0:
        print(mat(A[:K]))
    else:
        print(mat(A[-K:]))
elif np.count_nonzero(A_pn[:K]) % 2 == 0:
    print(mat(A[:K]))
elif N==K:
    print(mat(A))
else:
    negative_all = np.where(A_pn)[0]
    negative_rest = np.count_nonzero(negative_all>=K)
    if negative_rest == 0:
        # 負の数が残っていない
        A[negative_all[-1]] = A[K]
        print(mat(A[:K]))
    elif negative_rest == N-K:
        # 正の数が残っていない
        last_positive = np.where(A_pn[:K]==False)[0][-1]
        A[last_positive] = A[K]
        print(mat(A[:K]))
    elif len(negative_all)-negative_rest==K:
        # 負の数しか選択されていない
        last_negative = negative_all[negative_all<K][-1]
        next_positive = np.where(A_pn==False)[0][0]
        A[last_negative] = A[next_positive]
        print(mat(A[:K]))
    else:
        last_negative = negative_all[negative_all<K][-1]
        next_negative = negative_all[negative_all>=K][0]
        positive_all = np.where(A_pn==False)[0]
        last_positive = positive_all[positive_all<K][-1]
        next_positive = positive_all[positive_all>=K][0]
        if A[last_negative]*A[next_negative] > A[last_positive]*A[next_positive]:
            A[last_positive] = A[next_negative]
        else:
            A[last_negative] = A[next_positive]
        print(mat(A[:K]))
L,R,d = int(input().split())
count = 0
for i range(L,R+1):
  if i%d==0:
    count = count + 1
return count
    

### FIXED CODE ###

L,R,d = (input().split())
L = int(L)
R = int(R)
d = int(d)
count = 0
for i in range(L,R+1):
  if i%d==0:
    count = count + 1
print(count)
print(700+input.count('o')*100)

### FIXED CODE ###

print(700+input().count('o')*100)
#Attention

#ライブラリ
import copy

#入力
N = int(input())
S = list(input())
ans = []
#計算
for i in range(1,N-1,1):
	S_hidari = copy.copy(S[0:i])
	S_migi = copy.copy(S[i+1:N])
	if i == 1:
		ans.append(S_hidari.count('W')-1+S_migi.count('E'))
		break
	if i == N-2:
		ans.append(S_hidari.count('W')+S_migi.count('E')-1)
		break
	ans.append(S_hidari.count('W')+S_migi.count('E'))
	

print(min(ans))

### FIXED CODE ###

#Add Sub Mul

#入力
A,B = map(int,input().split())

#出力
print(max(A+B,A-B,A*B))
# -*- coding: cp932 -*-

import sys
import os
import re
import datetime
import bisect

def Test(value):
    a = [1,3,5]
    #x = 4

    insert_index = bisect.bisect_left(a, value)
    
    print("insert_index = ", insert_index)

####### main #######
    
if False:   
    while(True): 
        Test(int(input('? ')));
    sys.exit()
 
N = int(input())

partsNumA = sorted(map(int, input().split()))
partsNumB = sorted(map(int, input().split()))
partsNumC = sorted(map(int, input().split()))

# Bに対してAの個数のBによるループ
partsNumSumBa = []
sumA = 0
for curPartsB in partsNumB:
    indexA = bisect.bisect_left(partsNumA, curPartsB)
    numA = indexA
    sumA += numA
    partsNumSumBa.append(sumA)

# Cに対してBの個数のCによるループ
sumBAll = 0
for curPartsC in partsNumC:
    indexB = bisect.bisect_left(partsNumB, curPartsC)
    if indexB == 0:
        continue
    numB = partsNumSumBa[indexB - 1]
    sumBAll += numB
        
print(sumBAll)

### FIXED CODE ###

import sys
import os
import re
import datetime
import bisect

####### main #######

N = int(input())

partsNumA = sorted(map(int, input().split()))
partsNumB = sorted(map(int, input().split()))
partsNumC = sorted(map(int, input().split()))

# Bに対してAの個数のBによるループ
partsNumSumBa = []
sumA = 0
for curPartsB in partsNumB:
    indexA = bisect.bisect_left(partsNumA, curPartsB)
    numA = indexA
    sumA += numA
    partsNumSumBa.append(sumA)

# Cに対してBの個数のCによるループ
sumBAll = 0
for curPartsC in partsNumC:
    indexB = bisect.bisect_left(partsNumB, curPartsC)
    if indexB == 0:
        continue
    numB = partsNumSumBa[indexB - 1]
    sumBAll += numB

print(sumBAll)
def prod(li, MOD):
    ret = 1
    for a in li:
        ret *= a
        ret %= MOD
    return ret

N, K = map(int, input().split())
MOD = 1_000_000_007
aaa = list(map(int, input().split()))
aaa.sort(key=lambda x : abs(x))
if sum(a < 0 for a in aaa[-K:]) % 2 == 0:
    print(prod(aaa[-K:], MOD))
else:
    if all(a <= 0 for a in aaa):
        print(prod(aaa[:K], MOD))
    elif all(a <= 0 for a in aaa[:-K]):
        for a in aaa[-K:]:
            if a > 0:
                break
        bbb = aaa[-K:].remove(a)
        bbb.append(aaa[-(K + 1)])
        print(prod(bbb, MOD))
    elif all(a > 0 for a in aaa[:-K]):
        for a in aaa[-K:]:
            if a < 0:
                break
        bbb = aaa[-K:].remove(a)
        bbb.append(aaa[-(K + 1)])
        print(prod(bbb, MOD))
    else:
        bbb = aaa[-(K-1):]
        for a in aaa[:-K]:
            if a * aaa[-K] <= 0:
                bbb.append(a)
        print(prod(bbb, MOD))


### FIXED CODE ###

def prod(li, MOD):
    ret = 1
    for a in li:
        ret *= a
        ret %= MOD
    return ret

N, K = map(int, input().split())
MOD = 1_000_000_007
aaa = list(map(int, input().split()))
if N == K:
    print(prod(aaa, MOD))
    exit()
aaa.sort(key=lambda x : abs(x))
if sum(a < 0 for a in aaa[-K:]) % 2 == 0:
    print(prod(aaa[-K:], MOD))
else:
    if all(a <= 0 for a in aaa):
        bbb = aaa[:K]
    else:
        try:
            x1, y1 = min([a for a in aaa[-K:] if a > 0]), min([a for a in aaa[:-K] if a < 0])
        except:
            x1, y1 = 1, 0
        try:
            x2, y2 = max([a for a in aaa[-K:] if a < 0]), max([a for a in aaa[:-K] if a >= 0])
        except:
            x2, y2 = 1, 0
        bbb = aaa[-K:]
        if abs(x2 * y1) > abs(x1 * y2):
            bbb.remove(x1)
            bbb.append(y1)
        else:
            bbb.remove(x2)
            bbb.append(y2)
    print(prod(bbb, MOD))
import copy
N = int(input())
t = [int(x) for x in input().split()]
p = []
for _ in range(int(input())):
	p.append([int(x) for x in input().split()])

result = []
ori_t = copy.deepcopy(t)
for i,j in zip(t,p):
	t = copy.deepcopy(ori_t)
	t[j[0]-1] = j[1]
	result.append(sum(t))

print(result)


### FIXED CODE ###

print(eval(input()))
N,X=map(int,input().split())
length=list(map(int,input().split()))
ans=0
D=0

for i in range(N+1):
    if D<=X:
        ans+=1
    else:
        break
    D=D+length[i]
print(ans)


### FIXED CODE ###

N, X = map(int, input().split())
S = list(map(int, input().split()))
l = len(S)

ans = 1
num = 0

for i in range(l):
	num += S[i]
	if num <= X:
		ans += 1

print(ans)
import functools

input()

arr = list(sorted([(v, idx) for idx, v in enumerate(map(int, input().split()))], reverse=True))


@functools.lru_cache(maxsize=None)
def dp(l, r, idx):
    if idx == len(arr):
        return 0

    left = abs(arr[idx][1] - l) * arr[idx][0] + dp(l + 1, r, idx + 1)
    right = abs(arr[idx][1] - r) * arr[idx][0] + dp(l, r - 1, idx + 1)

    return max(left, right)


print(dp(0, len(arr) - 1, 0))


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 9)

input()

arr = list(sorted([(v, idx) for idx, v in enumerate(map(int, input().split()))], reverse=True))

d = [[-1 for _ in range(len(arr))] for _ in range(len(arr))]


def dp(l, r, idx):
    if idx == len(arr):
        return 0

    if d[l][r] != -1:
        return d[l][r]

    left = abs(arr[idx][1] - l) * arr[idx][0] + dp(l + 1, r, idx + 1)
    right = abs(arr[idx][1] - r) * arr[idx][0] + dp(l, r - 1, idx + 1)

    d[l][r] = max(left, right)
    return max(left, right)


print(dp(0, len(arr) - 1, 0))
from math import gcd
K = int(input())
 
c = 0
for i in range(1,K+1):
    for j in range(1,K+1):
      k = gcd(i,j)
        for l in range(1,K+1):
            a = gcd(k, l)
            c += a
 
print(c)

### FIXED CODE ###

from math import gcd
ans = 0
n = int(input())

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            l = gcd(i,j)
            ans += gcd(k,l)
print(ans)
'import zlib
print(eval(zlib.decompress(b\\'x\xda\xf3\xd3I\xb6\xcd\xcc+(-\xd1\xd0\xd4\x81\xd2\xd6\x05E\x99y%\x1a\xc9\xd1V\xc9z\xc9\xf9\xa5@\xa6z\x90\xbaf,\x8c\x1d\xae\xae\xa9\t\x00\xf0]\x11O\\')))'

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
fact = math.factorial
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
c = s()
num = c.count('R')
print(c[:num].count('W'))
n, m = map(int, input().split())
L=[set() for i in range(n)]
for i in range(m):
    a, b =  map(int, input().split())
    L[a-1] |= {b}
    L[b-1] |= {a}
Y = {range(1, n+1)}
Z = [0]*(n-1) 
S = {1}
def f(X):
    global S, Z
    D = set()
    for j in X:
        R = L[j-1]-S
        S |= L[j-1]
        D |= R
        for k in R:
          Z[k-2]=j
    if S == Y:
        print("Yes")
        print(Z[i] for i in range(n-1))
    else:
      f(D)
f({1})
    
    
    


### FIXED CODE ###

n, m = map(int, input().split())
import sys
sys.setrecursionlimit(10**6)
L=[set() for i in range(n)]
for i in range(m):
    a, b =  map(int, input().split())
    L[a-1] |= {b}
    L[b-1] |= {a}
Y = {range(1, n+1)}
Z = [0]*(n-1) 
S = {1}
def f(X):
    global S, Z
    X_next = set()
    for j in X:
        R = L[j-1]-S
        S |= L[j-1]
        X_next |= R
        for k in R:
            Z[k-2] += j
    if X_next == set():
        print("Yes")
        print('\n'.join(map(str, Z)))
    else:
        return  f(X_next)
f({1})
a = input()
s = input()

if a >= 3200:
	print(s)

elif a < 3200:
	print("red")

	


### FIXED CODE ###

a = int(input())
s = input()

if a >= 3200:
	print(s)

elif a < 3200:
	print("red")
a,b=map(str,input().split())
c.d=map(int,input().split())
e=input()
if c==e:
  print(c-1,d)
else:
  print(c,d-1)
 

### FIXED CODE ###

a,b=map(str,input().split())
c,d=map(int,input().split())
e=str(input())
if a==e:
    print(c-1,d)
else:
    print(c,d-1)
import math
a,b,x = map(int, input().split())

ans1 = (b-x/(a**2))*2/a
ans1 = math.degrees(math.asin(ans1))

ans2 = a*(b**2)/(2*x)
ans2 = math.degrees(math.atan(ans2))
print(min(ans1,ans2))

### FIXED CODE ###

import math
a,b,x = map(int, input().split())

theta1 = math.atan((2/a*(b-x/(a**2))))
if math.tan(theta1) <= 2*x/(a**3):
  print(math.degrees(theta1))
  exit()
else:
  theta2 = math.atan(a*b**2/(2*x))
  print(math.degrees(theta2))
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()                                                          
    return divisors
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。      
    # ref = random.choice(arr)                                                 
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

a = quick_sort(make_divisors(n))

if len(a)//2==0:
    x = len(a)//2-1
else:
    x = len(a)//2
xx = a[x]
yy= n//xx

print(xx-1+yy-1)

### FIXED CODE ###

import numpy as np
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()                                                          
    return divisors

a = np.sort(make_divisors(n))
#print(a)                                                                      
if len(a)//2==0:
    x = len(a)//2-1
else:
    x = len(a)//2

xx = a[x]
yy= n//xx

print(xx-1+yy-1)
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0
sum = 0

for i in range(len(dat)):
     sum = sum + dat[i]
		
print(sum)

### FIXED CODE ###

n = int(input())
dat = list(input().split())

dat = list(map(int,dat))

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(n):
	if i % 2 == 0:
		asum = asum + dat[i]
	else:
		bsum = bsum + dat[i]
		
print(asum-bsum)
s = input()

if(s = 'Sunny'):
    print('Cloudy')
elif(s = 'Cloudy'):
    print('Rainy')
else:
    print('Sunny')


### FIXED CODE ###

s = input()
l = ["Sunny","Cloudy","Rainy","Sunny"]
for i in range(3):
  if s==l[i]:
     print(l[i+1])
N = list(input())
N = [str(int(N[0]) - 1)] + ["9"] * (len(N)-1)
print("{:.0f}".format(sum(map(int, N)))

### FIXED CODE ###

S = list(input())
N = [str(int(S[0]) - 1)] + ["9"] * (len(S)-1)
print("{:.0f}".format(max(sum(map(int, N)), sum(map(int,S)))))
s = str(input())
ans=0
for in range s:
    if '+' Then:
        ans += 1
    else:
        ans -= 1

print(ans)

### FIXED CODE ###

s = str(input())
ans=0
for x in range(len(s)):
    if s[x] == '+':
        ans += 1
    else:
        ans -= 1

print(ans)
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
ad_list = [[] for _ in range(n)]
for a, b in ab:
  ad_list[a-1].append(b)
count = [0 for _ in range(n)]

def dfs(v, x):
  count[v] += x
  if len(ad_list[v]) == 0:
    return 0
  else:
    for ad_v in ad_list[v]:
      dfs(ad_v-1, x)
    return 0

for p, x in px:
  dfs(p-1, x)
print(*count)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.buffer.readline
def dfs(G,v,p):
    for nv in G[v]:
        if(nv==p):
            continue
        point[nv]+=point[v]
        dfs(G,nv,v)

N,Q=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
point=[0]*N
for i in range(Q):
    p,x=map(int,input().split())
    point[p-1]+=x
dfs(G,0,-1)
print(*point)
import sys
sys.setrecursionlimit(10000)

N=int(input())
A = []
for n in range(N):
    A.append(int(input()))


# N = 2*10**3
# A = [0 for n in range(N)]

# print(A)

visited = [False for n in range(N)]

dp = {}
def search(n,d):
    if n in dp:
        return dp[n]
    maxd = d
    for i in range(n)[::-1]:
        if i in dp:
            maxd = max(dp[i], maxd)
        elif A[i] >= A[n]:
            maxd = max(search(i,d+1), maxd)
    dp[n] = maxd
    return dp[n]

ds = [0 for n in range(N)]
for n in range(N)[::-1]:
    if not n in dp:
        ds[n] = search(n,0)

# print(ds)

print(max(ds)+1)

### FIXED CODE ###

import bisect
N=int(input())
a = []
for n in range(N):
    a.append(int(input()))

r = [-1]*N

mind = float("inf")
for n in range(N):
    ind = bisect.bisect_left(r, a[n])
    r[ind-1] = a[n]
    mind = min(mind, ind)

# print(r)
print(N-mind+1)
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
i=0
s=0
while D<=X:
  D+=L[i]
  s+=1
  i+=1
print(s)

### FIXED CODE ###

S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    n,x=L()
    l=L()
    ans=1
    d=0
    for i in range(n):
       d=d+l[i]
       if d<=x:
           ans+=1
    print(ans)
    

if __name__=='__main__':
    main()
n = int(input()) #長さ
a = map(int, input().split()) #帽子の数
x = 0
y = 0
z = 0
ans = 1

for i in range(n): #1文字目
  if a[i] == x:
    if x == y & x == z:
      ans = ans * 3
    elif x == y:
      ans = ans * 2
    x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
    z = z + 1
print(ans % 1000000007)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)
import sys
input = sys.stdin.readline
import math

N, X = map(int,input().split())
x = list(map(int,input().split()))

d = [abs(X-x[i]) for i in range(N)]
gcd = d[0]

for i in range(N-1):
    gcd = math.gcd(gcd,d[i+1])

print(gcd)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import math

N, X = map(int,input().split())
x = list(map(int,input().split()))

d = [abs(X-x[i]) for i in range(N)]
oppai = d[0]

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


for i in range(N-1):
    oppai = gcd(oppai,d[i+1])

print(oppai)
input_ = input()
print(chr(ord(str(input_)) + 1))

### FIXED CODE ###

input_ = raw_input()
print(chr(ord(str(input_)) + 1))
n,m,k=list(map(int,input().split()))
ans=0
curr=1
t=m-n+k+1
for i in range(n-k):
    curr=(curr*t)%998244353
    t+=1
t=m-n+k+1   
ans=max(0,curr)
for i in range(k+1):
    t-=1
    if t>0:
        curr=(curr*t)%998244353
    if curr>0:
        ans=(ans+curr)%998244353
print(ans)







### FIXED CODE ###

b=input()
a=input()
# print(a[:-1])
if len(a)==(len(b)+1) and a[:-1]==b:
    print("Yes")
else:
    print("No")
# https://atcoder.jp/contests/abc128/tasks/abc128_c

N, M = map(int, input().split())
k = []
s = []
for _ in range(M):
    std_in = list(map(int, input().split()))
    k.append(std_in[0])
    for i in range(std_in[0]):
        std_in[i+1] -= 1
    s.append(std_in[1:])
p = [int(i) for i in input().split()]

switches = [0] * N

def judge_bulbs(switches):
    for i in range(M):

        k_sum = 0
        for ki in range(k[i]):
            k_sum += switches[ki]

        if k_sum % 2 == p[i]:
            continue
        else:
            return False
    return True

def solve(idx, switches):
    if idx == N:
        if judge_bulbs(switches):
            return 1
        else:
            return 0

    ans = 0
    switches = switches.copy()
    
    ans += solve(idx+1, switches)

    switches[idx] = 1
    ans += solve(idx+1, switches)
    return ans

print(solve(0, switches))





### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
s = [LIST()[1:] for _ in range(M)]
p = LIST()

ans = 0
for x in product([0, 1], repeat=N):
    for i in range(M):
    	cnt = 0
    	for n in s[i]:
    		if x[n-1] == 1:
    			cnt += 1
    	if cnt%2 != p[i]:
    		break
    else:
    	ans += 1
print(ans)
def main():
    H,W,K = map(int,input().split())
    S = [[int(s) for s in input()]for _ in range(H)]
    ans = 10**9
    for i in range(2**(H-1)):
        aa = 0
        for j in range(H-1):
            if (i>>j)&1 == 1:
                aa+=1
        c = aa
        b = [0 for _ in range(c+1)]
        OK = True
        for j in range(W):
            k = 0
            for h in range(H):
                if S[h][j] == 1:b[k] += 1
                if (i>>j)&1==1:k+=1
            
            ok = True
            for p in b:
                if p > K:ok = False
            if not ok:
                aa += 1
                b = [0]*(c+1)
                k = 0
                for h in range(H):
                    if S[h][j]==1:b[k] += 1
                    if (i>>j)&1==1:k+=1
            ok = True
            for p in b:
                if p > K:ok = False
            if not ok:OK = False;break                
        if OK:ans = min(ans,aa)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    H,W,K = map(int,input().split())
    S = [input()for _ in range(H)]
    ans = 10**9
    for i in range(2**(H-1)):
        aa = 0
        for j in range(H-1):
            if (i>>j)&1 == 1:
                aa+=1
        c = aa
        b = [0]*(c+1)
        OK = True
        for j in range(W):
            k = 0
            for h in range(H):
                if S[h][j] == "1":b[k] += 1
                if (i>>h)&1==1:k+=1
            
            ok = True
            for p in b:
                if p > K:ok = False
            if not ok:
                aa += 1
                b = [0]*(c+1)
                
                k = 0
                for h in range(H):
                    if S[h][j]=="1":b[k] += 1
                    if (i>>h)&1==1:k+=1
                ok = True
                for p in b:
                    if p > K:ok = False
                if not ok:OK = False;break                
        if OK:ans = min(ans,aa)
    print(ans)

if __name__ == "__main__":
    main()
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
 
ans = 0
time = 0
a_time = 0
temp = 0
if a[0] > k:
    j = 0
    while time <= k:
        time += b[j]
        j += 1
        ans += 1
else:
    for i in range(n):
        a_time += a[i]
        if a_time > k:
            break
        else:
            time = a_time
            temp = i + 1
            j = 0
            while time <= k:
                time += b[j]
                j += 1
                temp +=1
            temp += j
            if temp > ans:
                ans = temp
                
print(ans)

### FIXED CODE ###

n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_a = [0]
sum_b = [0]

for i in range(n):
    sum_a.append(sum_a[i] + a[i])
for j in range(m):
    sum_b.append(sum_b[j] + b[j])

temp = 0
j = m
ans = 0
for i in range(n+1):
    if sum_a[i] > k:
        temp = i -1
        if temp > ans:
            ans = temp
        break
    else:
        while k - sum_a[i] < sum_b[j]:
            j -= 1
        temp = i + j
        if temp > ans:
            ans = temp
            
print(ans)