Harryxun/stf_run huggingface dataset:
ans = 0
flg = 0
for i in range(int(input())):
  for j in range(int(input())):
    for k in range(int(input())):
      if flg == 0:
        x = int(input())
      flg+=1
      if 500*i+100*j+50*k==x:
        ans+=1
print(ans)

### FIXED CODE ###

a = [int(input()) for i in range(4)]
ans = 0
for i in range(a[0]+1):
  for j in range(a[1]+1):
    for k in range(a[2]+1):
      if 500*i+100*j+50*k==a[3]:
        ans+=1
print(ans)
s,w = map(int, input().split())
if s>f:
    print('safe')
else:
    print('unsafe')

### FIXED CODE ###

s,w = map(int, input().split())
if s>w:
    print('safe')
else:
    print('unsafe')
import math
a,b,c = map(int, input().split('.'))
print(math.floor(a*b + a*c/100))

### FIXED CODE ###

import math
a,b = map(str, input().split())
ia = int(a)
ib1,ib2 = map(int, b.split('.'))
print(math.floor(ia*ib1 + ia*ib2//100))
N = int(input())
S = [input() for _ in range(N)]
print(len(set(s)))

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
print(len(set(S)))
a,b=(int(i)for i in input().split())

print(6-a-b)

### FIXED CODE ###

a=int(input())
b=int(input())

print(6-a-b)
while 1:
    n = int(input())
    a = [int(input()) for _ in range(n)]

    dp = [a[0]]
    for i in range(1,len(a)):
        dp.append(max(dp[i-1] + a[i], a[i]))

    print(max(dp))

### FIXED CODE ###

while 1:
    n = int(input())
    if n == 0:
        break
    a = []
    for _ in range(n):
        a.append(int(input()))

    dp = []
    dp.append(a[0])
    for i in range(1,len(a)):
        dp.append(max(dp[i-1] + a[i], a[i]))

    print(max(dp))
s = input()


count = 0
for i in range(len(s)):
  if s[i] == "P" && s[i + 1] == "D":
    count += 1
  elif s[i] == "D":
    count += 1
  elif s[i] == "?" && s[i + 1] == "D":
    count += 1
    
print(count)


### FIXED CODE ###

a,b,c,d,e = map(int, input().split())

wake = a * 60 + b
gobed = c * 60 + d

time = gobed - wake

if time > e:
  print(time - e)
elif time == e:
  print(0)
import math
n = int(input())
a = []
m = n
for i in range(n):a.append(list(map(int, input().split())))

def distant(x1, y1, x2, y2):
    return math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)

ma = 0
while(m!=0):
    for i in range(m):
        if(i != m-1):
            p = distant(a[i][0], a[i][1], a[m - 1][0], a[m - 1][1])

            #print(p)
            #print(a[i][0], a[i][1], a[m-1][0], a[m-1][1])

            ma = max(ma, p)
    m = m - 1
print(ma/2)

### FIXED CODE ###

s = "abcdefghijklmnopqrstuvwxyz"
c = input()
print(s[s.index(c)+1])
##E
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

psum = 0
plist = []

for i in range(X):
        plist.append(p[i])
for i in range(Y):
        plist.append(q[i])
        
plist.sort()
        
for i in range(C):
    if r[i] > plist[0]:
        plist.pop(i)
        plist.append(r[i])
        
print(sum(plist))

### FIXED CODE ###

##E
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

psum = 0

for i in range(X):
        r.append(p[i])
for i in range(Y):
        r.append(q[i])
        
r.sort(reverse=True)
ans = 0

for i in range(X+Y):
		ans += r[i]

        
print(ans)
def test():
    global count, list_str
    for i, data in enumerate(list_str):
        try:
            if data == '#' and list_str[i + 1] == '.':
                list_str[i + 1] = '#'
                count += 1
                test()
        except IndexError:
            pass


N = input()
S = input()
count = 0

list_str = list(S)


test()

# print(list_str)
print(count)

### FIXED CODE ###

N = input()
S = input()
count = 0

list_str = S
count_black = 0
count_white = S.count('.')
ans = count_black + count_white

for i in S:
    if i == '#':
        count_black += 1
    else:
        count_white -= 1

    if ans >= count_white + count_black:
        ans = count_black + count_white

# print(count_black)
# print(count_white)

print(ans)
S = list(input())
N = len(S)
c=0
i=0
f=0
while(1):
    if S[i] != S[i+1]:
        del S[i:i+2]
        c+=2
        N-=2
        i-=1
        f=1
    i+=1
    if i+1 == N:
        i=0
        if f==0:
            break
        f=0
print(c)

### FIXED CODE ###

S = list(input())
N = len(S)

c=0
i=0
f=0
while(1):
    if i+1 == N or N < 2:
        break
    if S[i] != S[i+1]:
        del S[i:i+2]
        c += 2
        N -= 2
        if i >= 1:
            i -= 2
        else:
            i -= 1
    i += 1
    #print(i,N,S,f)                                                                      
print(c)
X, A, B = map(int, raw_input().split())
if A <= B:
  print 'delicious'
else
  print 'dangerous' if X < B-A else 'safe'

### FIXED CODE ###

X, A, B = map(int, raw_input().split())
if B-A > X:
  print 'dangerous'
else:
  print 'safe' if A < B else 'delicious'
def FACT(DICT, N):
    FACT = DICT
    LIM = int((N**0.5)//1)+1
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
        if len(FACT) == len(DICT):
            FACT[N] = 1
            return FACT
    return FACT(FACT, N)

def comb_rep(n, r):
    N = n+r-1
    ANS = 1
    for R in range(r):
        ANS *= N-R
        ANS /= R+1
    return int(ANS)

n, m = map(int, input().split())
factor = FACT({}, m)
ans = 1
for i in factor:
    ans *= comb_rep(n, factor[i])
print(ans)

### FIXED CODE ###

def FACTOR(DICT, N):
    FACT = DICT
    LIM = int(N**0.5)+2
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
    if len(FACT) == len(DICT):
        if N != 1:
            FACT[N] = 1
        return FACT
    return FACTOR(FACT, N)

def comb_rep(n, r):
    N = n+r-1
    ANS = 1
    for R in range(r):
        ANS *= N-R
    for R in range(r):
        ANS //= r-R
    return int(ANS)

MOD = 10**9+7
n, m = map(int, input().split())
factor = FACTOR({}, m)
ans = 1
for i in factor:
    ans *= (comb_rep(n, factor[i])%MOD)
    ans %= MOD
print(ans)
a=int(input)
b=int(input)

print(6-a-b)

### FIXED CODE ###

a=int(input())
b=int(input())

print(6-a-b)
n = int(input())

for i in range(n):
    if 2**i > n:
        ans = 2**(i-1)
        break

print(ans)


### FIXED CODE ###

n = int(input())

if n == 1:
    print("1")
    exit()

for i in range(n):
    if 2**i > n:
        ans = 2**(i-1)
        break

print(ans)
n = int(input())
a = list(map(int,input().split()))

res = 0
rright = 0
sum = 0
for left in range(n):
    while (right < n and sum^a[right] == sum+a[right]):
        sum += a[right]
        right += 1
    res += right - left
    if left == right:
        right += 1
    else:
        sum -= a[left]
print(res)

### FIXED CODE ###

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

res = 0
right = 0
sum = 0
for left in range(n):
    while (right < n and sum^a[right] == sum+a[right]):
        sum += a[right]
        right += 1
    res += right - left
    if left == right:
        right += 1
    else:
        sum -= a[left]
print(res)
def main():
    A = [list(map(int, input().split())) for i in range(3)]
    N = int(input())
    b = [int(i) for i in range(N)]
    
    for i in range(3):
        for j in range(3):
            for k in range(N):
                if (A[i,j] == b(k)):
                    A[i,j] = 0
    
    ans = "No"
    for i in range(3):
        if A[i,0]==A[i,1]==A[i,2]==0: ans = "Yes"
        if A[0,i]==A[1,i]==A[2,i]==0: ans = "Yes"
    if A[0,0]==A[1,1]==A[2,2]==0: ans = "Yes"
    if A[0,2]==A[1,1]==A[2,0]==0: ans = "Yes"
    print(ans)
main()

### FIXED CODE ###

def main():
    A = [list(map(int, input().split())) for i in range(3)]
    N = int(input())
    b = [int(input()) for i in range(N)]
    
    for i in range(3):
        for j in range(3):
            for k in range(N):
                if A[i][j] == b[k]:
                    A[i][j] = 0
    
    ans = "No"
    for i in range(3):
        if A[i][0]+A[i][1]+A[i][2]==0:
            ans = "Yes"
        if A[0][i]+A[1][i]+A[2][i]==0:
            ans = "Yes"
    if A[0][0]+A[1][1]+A[2][2]==0:
        ans = "Yes"
    if A[0][2]+A[1][1]+A[2][0]==0:
        ans = "Yes"
    print(ans)
main()
import sys
import math
N,D=map(int,sys.stdin.readline().split())
x=[]
count=0
for i in range(N):
    x.append(map(int,sys.stdin.readline().split()))
for i in range(N):
    for j in range(n-1):
        if j>=i:
            k=j+1
        else:
            k=j
        diff=math.sqrt(sum([(a-b)**2 for a,b in x[i],x[k]]))
        if diff-int(diff)==0:
            count+=1
print(count)


### FIXED CODE ###

import sys
import math
N,D=map(int,sys.stdin.readline().split())
x=[]
count=0
for i in range(N):
    x.append(list(map(int,sys.stdin.readline().split())))

for i in range(N):
    for j in range(i+1,N):

        diff=math.sqrt(sum([(a-b)**2 for a,b in zip(x[i],x[j])]))

        if diff-int(diff)==0:
            count+=1
print(count)
n, m = map(int, input().split())
group_idx = [i for i in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  if a > b:
    a, b = b, a
  group_idx[b - 1] = group_idx[a - 1]
  print(group_idx)

groups = [0 for i in range(n)]

for i in range(n):
  groups[group_idx[i]] += 1

print(group_idx)
print(max(groups))

### FIXED CODE ###

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
n, m = map(int, input().split())
par = [-1]*n

for i in range(m):
  a, b = map(int, input().split())
  unite(a - 1, b - 1)

ans = 0
for i in range(n):
  ans = max(ans, size(i))

print(ans)
n,m = map(int,input().split())
li=list(map(int,input().split()))
if m>=n:
    print(0)
else:
    sort(li)
    print(sum(li[n-m:]))

### FIXED CODE ###

n,m = map(int,input().split())
li=list(map(int,input().split()))
if m>=n:
    print(0)
else:
    li.sort()
    print(sum(li[:n-m]))
n = int(input())
a = [int, for i in input().split()]
b = [int, for i in input().split()]
c = 0

for i in range(n):
	if a[i] >= b[i]:
		c += b[i]
	else:
		c += a[i]
		c += min(a[i+1],b[i]-a[i])
		if a[i+1] >= b[i]-a[i]:
			a[i+1] = a[i+1] - (b[i] - a[i])
		else:
			a[i+1] = 0
print(c)

### FIXED CODE ###

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

if (A+B)%2 == 1 :
	print('IMPOSSIBLE')
else :
	print((A+B)//2)
K = list(map(int, input().strip()))
D = int(input())
mod = 10**9+7
a = 0
for i in range(1, J+1):
    if sum(map(int, str(i))) % D == 0:
        a += 1
print(a%mod)
dp = [0]*D
dp[0] += 1
S = 0
for k in K:
    dp[S%D] -= 1
    dp2 = [0]*(D+10)
    for j, d in enumerate(dp):
        dp2[j] += d
        dp2[j+10] -= d
    for j in range(1, D+10):
        dp2[j] = (dp2[j-1] + dp2[j]) % mod
    for j in range(10):
        dp2[(D+j)%D] = (dp2[(D+j)%D] + dp2[D+j]) % mod 
    dp = dp2[:D]
    for j in range(k+1):
        dp[(S+j)%D] = (dp[(S+j)%D] + 1)%mod
    S += k
print((dp[0]-1)%mod)

### FIXED CODE ###

K = list(map(int, input().strip()))
D = int(input())
mod = 10**9+7

dp = [0]*D
dp[0] += 1
S = 0
for k in K:
    dp[S%D] -= 1
    dp2 = [0]*(D+10)
    for j, d in enumerate(dp):
        dp2[j] += d
        dp2[j+10] -= d
    for j in range(1, D+10):
        dp2[j] = (dp2[j-1] + dp2[j]) % mod
    for j in range(10):
        dp2[(D+j)%D] = (dp2[(D+j)%D] + dp2[D+j]) % mod 
    dp = dp2[:D]
    for j in range(k+1):
        dp[(S+j)%D] = (dp[(S+j)%D] + 1)%mod
    S += k
print((dp[0]-1)%mod)
a,b,c = map(int, input().split())
if b − a == c − b:
  print("YES")
else:
  print("NO")
 


### FIXED CODE ###

a,b,c = map(int, input().split())
if (b - a) == (c - b):
  print("YES")
else:
  print("NO")
N = input()

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

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        for c in range(b+1, N):
            if A[c] < (A[a] + A[b]):
                ans += 1
                print(a, b, c)
            else:
                break

print(ans)

### FIXED CODE ###

import bisect

N = int(input())

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

A.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        ans += bisect.bisect_left(A, A[a]+A[b])-b-1

print(ans)
N = [int(i) for i in str(input())]
m = len(N)
K = int(input())
dp = [[[0 for i in range(m + 1)],[0 for i in range(m + 1)]]   for i in range(m)]
#初期条件
dp[0][1][0] = 1
dp[0][0][1] = 1
dp[0][1][1] = N[0] - 1
for i in range(1,m):
    for t in range(0,min(i+2,K+1)):
        if N[i] != 0:
            if t == 0:
                dp[i][1][t] = dp[i-1][1][t]
            else:
                dp[i][0][t] = dp[i-1][0][t-1]
                dp[i][1][t] = dp[i-1][0][t] + dp[i-1][0][t-1] * (N[i]-1) + dp[i-1][1][t] + dp[i-1][1][t-1] * 9
        else :
            if t == 0:
                dp[i][0][t] = dp[i-1][0][t]
                dp[i][1][t] = dp[i-1][1][t] * 1
            else :
                dp[i][0][t] = dp[i-1][0][t] + dp[i-1][1][t] + dp[i-1][1][t-1] * 9
print(dp[-1][0][K]+dp[-1][1][K])


### FIXED CODE ###

N = [int(i) for i in str(input())]
m = len(N)
K = int(input())
dp = [[[0 for i in range(K + 1)],[0 for i in range(K + 1)]]   for i in range(m)]
#初期条件
dp[0][1][0] = 1
dp[0][0][1] = 1
dp[0][1][1] = N[0] - 1
for i in range(1,m):
    for t in range(0,min(i+2,K+1)):
        if N[i] != 0:
            if t == 0:
                dp[i][1][t] = dp[i-1][1][t]
            else:
                dp[i][0][t] = dp[i-1][0][t-1]
                dp[i][1][t] = dp[i-1][0][t] + dp[i-1][0][t-1] * (N[i]-1) + dp[i-1][1][t] + dp[i-1][1][t-1] * 9
        else :
            if t == 0:
                dp[i][0][t] = dp[i-1][0][t]
                dp[i][1][t] = dp[i-1][1][t] 
            else :
                dp[i][0][t] = dp[i-1][0][t]
                dp[i][1][t] = dp[i-1][1][t] + dp[i-1][1][t-1] * 9
print(dp[-1][0][K]+dp[-1][1][K])
import math
r = int(input())
print(r**2*math.pi, 2*r*math.pi)

### FIXED CODE ###

import math
r = float(input())
print(r**2*math.pi, 2*r*math.pi)
S=input()
count=0
for i in range(S):
  if S[i]!=S[-i-1]:
    count+=1
print(count)

### FIXED CODE ###

S=input()
count=0
for i in range(len(S)//2):
  if S[i]!=S[-i-1]:
    count+=1
print(count)
l=int(input())
print({:.10d}.format(l/3))

### FIXED CODE ###

l=int(input())
i=l/3
print(i**3)
n,k = map(int,input().split())
if n > 0:
  n = n-k
elif n == 0:
  n = 0
else:
  m = abs(n-k)
print(min(n,abs(n-k))

### FIXED CODE ###

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

print(min(N%K,abs(N%K-K)))
S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60
print(h:m:s)


### FIXED CODE ###

S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60
print(f'{h}:{m}:{s}')
print("A{}C".format(input()[8])

### FIXED CODE ###

print("A" + input()[8] + "C")
W,H,N = map(int,input().split(" "))
Lx = [1 for i in range(N)]
Ly = [1 for i in range(N)]

for i in range(N):
  xi,yi,ai = map(int,input().split(" "))
  if ai ==1:
    for j in range(xi):
      Lx[j] = 0
         
  if ai ==2:
    for j in range(xi,W):
      Lx[j] = 0
    
  if ai ==3:
    for j in range(yi):
      Ly[j] = 0
    
  if ai ==4:
    for j in range(yi,H):
      Ly[j] = 0
x = sum(Lx)
y = sum(Ly)

print(x*y)
    
  
  

### FIXED CODE ###

W,H,N = map(int,input().split(" "))
Lx = [1 for i in range(W)]
Ly = [1 for i in range(H)]
 
for i in range(N):
  xi,yi,ai = map(int,input().split(" "))
  if ai ==1:
    for j in range(xi):
      Lx[j] = 0
         
  if ai ==2:
    for j in range(xi,W):
      Lx[j] = 0
    
  if ai ==3:
    for j in range(yi):
      Ly[j] = 0
    
  if ai ==4:
    for j in range(yi,H):
      Ly[j] = 0
x = sum(Lx)
y = sum(Ly)
 
print(x*y)
N,K=map(int,input().split())
a=list(map(int,input().split()))
if K>=N:
	print(0)
else:
	b=sorted(a)
	c=0
	for i in range(N-K):
		c+=b[i]
	print(c)

### FIXED CODE ###

H, A=map(int,input().split())
if H//A==H/A:
	print(H//A)
else:
	print(H//A+1)
N = int(input())
A = np.array(list(sorted(map(int, input().split()))), dtype=int)
B = np.array(list(sorted(map(int, input().split()))), dtype = int)
C = np.array(list(sorted(map(int, input().split()))), dtype = int)
 
upper_condition = np.array([1 + np.max(np.where(A < b)[0]) for b in B])
lower_condition = np.array([N - np.min(np.where(C > b)[0]) for b in B])
 
print(np.sum(upper_condition*lower_condition))

### FIXED CODE ###

N = int(input().rstrip())
A = sorted(list(map(int, input().rstrip().split())))
B = sorted(list(map(int, input().rstrip().split())))
C = sorted(list(map(int, input().rstrip().split())))

import bisect
upper_condition = [bisect.bisect_left(A, b) for b in B]
lower_condition = [N - bisect.bisect_right(C, b) for b in B]

print(sum(map(lambda x: x[0]*x[1], zip(upper_condition, lower_condition))))
a,b,c = map(int,input().split())

if a+b = c or a+c = b or b+c = a:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b,c = map(int,input().split())

if a+b == c or b+c == a or a+c == b:
    print("Yes")
else:
    print("No")
A,B,C = [int(_) for _ in input().split]
n = min(B//A,C)
print(n)

### FIXED CODE ###

A,B,C = [int(_) for _ in input().split()]
n = min(B//A,C)
print(n)
K = int(input())

if K % 2:
    print((K // 2) * (K // 2 + 1))
else:
    print((K // 2)**2)


### FIXED CODE ###

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

if C <= B / A:
    print(C)
else:
    print(int(B / A))
h,a=map(int, input().solit())
if h%a==0:
  print(h/a)
else:
  print(int(h//a)+1)

### FIXED CODE ###

h,a=map(int,input().split())
if h%a==0:
  print(int(h/a))
else:
  print(int(h//a)+1)
def BF(p,n,s):
    inf=float("inf")
    d=[inf for i in range(n)]
    d[s-1]=0
    for i in range(n+1):
        for e in p:
            if e[0]!=inf and d[e[1]-1]>d[e[0]-1]+e[2]:
                d[e[1]-1] = d[e[0]-1] + e[2]
                if i==n: return [0,'inf']
    return list(map(lambda x:-x, d))
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a=[[x,y,-z] for x,y,z in a]
print(BellmanFord(a, n, 1)[-1])

### FIXED CODE ###

def BF(p,n,s):
    inf=float("inf")
    d=[inf for i in range(n)]
    d[s-1]=0
    for i in range(n+1):
        for e in p:
            if e[0]!=inf and d[e[1]-1]>d[e[0]-1]+e[2]:
                d[e[1]-1] = d[e[0]-1] + e[2]
        if i==n-1:t=d[-1]
        if i==n and t!=d[-1]:
            return [0,'inf']
    return list(map(lambda x:-x, d))
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a=[[x,y,-z] for x,y,z in a]
print(BF(a, n, 1)[-1])
N, A = map(int, input().split())

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

maxint = 50 * max(x)

dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]

dp[0][0][0] = 1

for xi, xe in enumerate(x, 1):
    for j in range(xi+1):
        for k in range(maxint + 1):
            dp[xi][j][k] = dp[xi - 1][j][k]
            
            if j >= 0 and k >= xe:
                dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
                

res = 0

for i in range(1, N+1):
    res += dp[N][i][i * A]

print(res)

### FIXED CODE ###

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

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

maxint = 50 * N

dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]

dp[0][0][0] = 1

for xi, xe in enumerate(x, 1):
    for j in range(xi+1):
        for k in range(maxint + 1):
            dp[xi][j][k] = dp[xi - 1][j][k]
            
            if j >= 0 and k >= xe:
                dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
                

res = 0

for i in range(1, N+1):
    res += dp[N][i][i * A]

print(res)
def main(n, s: list, m, t: list):
    choices = set(s + t)

    ans = [0]

    for choice in choices:
        ans_t = 0
        for _s in s:
            if choice == _s:
                ans_t += 1
        for _t in t:
            if choice == _t:
                ans_t -= 1

        ans.append(ans_t)

    print(max(ans))


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(n)]

    main(n, s, m, t)


### FIXED CODE ###

def main(n, s: list, m, t: list):
    choices = set(s + t)

    ans = [0]

    for choice in choices:
        ans_t = 0
        for _s in s:
            if choice == _s:
                ans_t += 1
        for _t in t:
            if choice == _t:
                ans_t -= 1

        ans.append(ans_t)

    print(max(ans))


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(m)]

    main(n, s, m, t)
n,q=map(int,input().split())
S=input()
L=[list(map(int,input().split())) for i in range(q)]

s=[0]*(n+1)
for i in range(1,n+1):
    if S[i-1]=='A' and S[i]=='C':
        s[i]=s[i-1]+1
    else:
        s[i]=s[i-1]

#print(s)
for l,r in L:
    ans=s[r-1]-s[l-1]
    print(ans)

### FIXED CODE ###

#122-C
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
m=[0]*(n+1)
for i in range(len(s)-1):
    
    if s[i]=='A' and s[i+1]=='C':
        m[i+1]=m[i]+1
    else:
        m[i+1]=m[i]

for i in l:
    print(m[i[1]-1]-m[i[0]-1])
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort(reverse=True)
pcount=0
qcount=0
rcount=0
ans=[]
for i in range(x):
  ans.append(p[-1-i])
for i in range(y):
  ans.append(q[-1-i])
ans.sort()
print(ans,r)
for i in range(c):
  if ans[i]<=r[rcount]:
    ans[i]=r[rcount]
    rcount+=1
print(sum(ans))

### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort(reverse=True)
rcount=0
ans=[]
for i in range(x):
  ans.append(p[-1-i])
for i in range(y):
  ans.append(q[-1-i])
ans.sort()
for i in range(min(len(ans),c)):
  if ans[i]<=r[rcount]:
    ans[i]=r[rcount]
    rcount+=1
print(sum(ans))
s=input()
t=s[::-1]
n=len(input())
if n%2==0:
  x=n//2
else:
  x=n//2+1
count=0
  for i in range(x):
      if s[i]!=t[i]:
            count+=1
print(count)

### FIXED CODE ###

s=input()
n=len(s)
cnt=0
if n%2==0:
  for i in range(n//2):
    if s[:n//2][::-1][i]!=s[n//2:n][i]:
      cnt+=1
  print(cnt)
else:
  for i in range(n//2):
    if s[:(n-1)//2][::-1][i]!=s[(n+1)//2:n][i]:
      cnt+=1
  print(cnt)
N, Q = map(int, input().split())
root = [[] for _ in range(N)]
ans = [0] * N

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    root[a].append(b)
    root[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

visit = [False] * N
def dfs(n):
    visit[n] = True
    for go in root[n]:
        if visit[go]:
            continue
        ans[go] += ans[n]
        dfs(go)

dfs(0)
print(*ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7


n, q = map(int, input().split())
g = [[] for _ in range(n)]
val = [0] * n

for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

for _ in range(q):
    p, x = map(int, input().split())
    val[p - 1] += x

seen = [False] * n
def dfs(v):
    seen[v] = True
    for nv in g[v]:
        if seen[nv]:
            continue
        val[nv] += val[v]
        dfs(nv)

dfs(0)
print(*val)