Harryxun/stf_run huggingface dataset:
from collections import Counter
n = int(input())
s, t = Counter(int)
for _ in n:
    word = input()
    s[word] += 1
m = int(input())
for _ in m:
    word = input()
    s[word] -= 1
print(s.most_common(1))
    

### FIXED CODE ###

from collections import Counter, defaultdict
n = int(input())
s= []
t = defaultdict(int)
for _ in range(n):
    s.append(input())
u = Counter(s)
m = int(input())
for _ in range(m):
    word = input()
    t[word] -= 1
    if word in u.keys():
        u[word] -= 1

ans = u.most_common(1)[0][1]
t = sorted(t.items(), key=lambda x:x[1], reverse=True)[0][1]
t = max(t, 0)
print(max(ans,t))
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

l = 0
w = len(A[0])
while l <= len(A) - len(B):
	for n in range(len(A) - len(B)):
		if B[0] not in A[n][l:]:
			continue
		if 0 == A[n][l:].index(B[0]):
			for m in range(1, len(B)):
				if 0 != A[n + m][l:].index(B[m]):
					break
				else:
					#print(n, m)
					print("Yes")
					exit()
	l += 1
print("No")


### FIXED CODE ###

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

l = 0
while l <= len(A[0]) - len(B[0]):
	for i in range(N - M + 1):
		s = A[i][l:]
		if not B[0] in s:
			continue
		if 0 == s.index(B[0]):
			for m in range(1, M):
				if not B[m] in A[i + m][l:]:
					break
				if 0 != A[i + m][l:].index(B[m]):
					break
			else:
				print("Yes")
				exit()
	l += 1
print("No")
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnt = 0
while k > 0:
    if a == []:
        a = [1001001001]
    if b == []:
        a = [1001001001]
    if a[0] < b[0]:
        if k - a[0] < 0:
            print(cnt)
            exit()
        k -= a[0]
        cnt += 1
        a.remove(a[0])
    else:
        if k - b[0] < 0:
            print(cnt)
            exit()
        k -= b[0]
        cnt += 1
        b.remove(b[0])

print(cnt)

### FIXED CODE ###

n, m, k = map(int,input().split())
a = [0] + list(map(int,input().split()))
b = [0] + list(map(int,input().split()))

for i in range(1, n+1):
    a[i] += a[i-1]
    
for j in range(1, m+1):
    b[j] += b[j-1]
    
ans = 0
bc = m

for ac in range(n+1):
    if a[ac] > k:
        continue
    
    while a[ac] + b[bc] > k:
        bc -= 1
        
    ans  = max(ans, ac+bc)

print(ans)
N = int(input())
A = list(map(int, input().split()))
import copy
ori = copy.copy(A)

for i in range(N):
    A[i] -= (N - 1) - i
# print(A)
# import collections
# dct = dict(collections.Counter(A))
# print(dct)
# m = min(A)
# cnt = 0
# for check in range(m, 0):
#
#     if dct.get(check, 0):
#         print(check)
#         cnt += dct[check] * dct.get(check + 2, 0)
# print(cnt)
remove = 0
# for i in range(N-2):
#     if ori[i] != 1 and ori[i] == ori[i + 2]:
#         remove += 1
for i in range(N - 1):
    if ori[i] + 1 == ori[i + 1]:
        remove += 1
# print(ori)
# print(cnt - remove)

bucket = [0] * N
cnt = 0
for i in range(N):
    if A[i] < 0:
        bucket[-A[i]] += 1
        cnt += bucket[-A[i] + 2]
print(cnt- remove)



### FIXED CODE ###

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

L = [A[i] + (i + 1) for i in range(N)]
R = [(i + 1) - A[i] for i in range(N)]
import collections
dL = dict(collections.Counter(L))
dR = dict(collections.Counter(R))

ans = 0
for k in dL.keys():
    ans += dL[k] * dR.get(k, 0)
print(ans)
# print(L)
# print(R)
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;
ll N;
vector<ll> H, S;
vector<bool> seen;
vector<ll>sum;
vector<int> pl;

bool isYes(ll mid)
{
	vector<ll> count(N, 0);
	for (ll i = 0; i < N; ++i)
	{
		if (mid - H[i] < 0) return false;
		++count[min(N-1, (mid - H[i]) / S[i])];
	}
	for (ll i = 0; i < N-1; ++i)
		count[i+1] += count[i];
	for (ll i = 0; i < N; ++i)
		if (count[i] > i+1)
			return false;
	return true;
}
//普通の深さ優先探索seenを返す感じ
void dfs2(const G &G,int v){
    seen[v] = true; //v探索済み
	sum[v]+=pl[v];

    for(auto next_v :G[v]){
        if(seen[next_v])continue;//もう探索していた
		sum[next_v]+=sum[v];
        dfs2(G,next_v);
    }
}

void dfs(const G &G, int v, int p) {
	sum[v]+=pl[v];

    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
		sum[nv]+=sum[v];
        dfs(G, nv, v); // v は新たに nv の親になります
    }
}

int main(int argc, char **argv){
	ll n,q; cin>>n>>q;
	G graph(n);
	sum.assign(n,0);
	pl.assign(n,0);

	rep(i,0,n-1){
		int a,b; cin>>a>>b;
		graph[a-1].push_back(b-1);
	}
	rep(i,0,q){
		int p,x; cin>>p>>x;
		pl[p-1]+=x;
	}

	seen.assign(n,false);
	rep(i,0,n){
		dfs2(graph,i);
	}

	rep(i,0,n){
		cout<<sum[i]<<" ";
	}

}


### FIXED CODE ###

n, q = map(int,input().split())
tree = [[] for i in range(n)]
v = [0]*n
for i in range(n-1):
    a1,b1 = [int(i) for i in input().split()]
    tree[a1-1].append(b1)
for i in range(q):
    p1,x1 = [int(i) for i in input().split()]
    v[p1 - 1] += x1
for i in range(n):
    for j in range(len(tree[i])):
        v[tree[i][j]-1] += v[i]
for i in range(n):
    print(str(v[i]) +" ",end="")
import math

n, m = [int(x) for x in input().split()]
a = list(map(int, input().split()))

a = sorted(a, reverse=True)

for i in range(m):
    a[0] = math.floor(a[0] / 2)
    if a[0] < a[1]:
        a = sorted(a, reverse=True)

print(sum(a))


### FIXED CODE ###

s = input()
 
if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
k, x = map(int, input())
sa = k-1
zahyous = []
for add in range(-sa, sa+1):
  zahyous.append(str(x + sa))
ret_val = " ".join(zahyous)
print(ret_val)

### FIXED CODE ###

k, x = map(int, input().split())
sa = k-1
zahyous = []
for add in range(-sa, sa+1):
  zahyous.append(str(x + add))
ret_val = " ".join(zahyous)
print(ret_val)
s = int(input())
x = 1
if s == 1 or s == 2:
    print(4)
else:
    while not s == 4:
        if s % 2 != 0:
            s = 3 * s + 1
            x = x + 1
               
        else:
            s = s // 2
            x = x + 1
        
        
print(x + 3)

### FIXED CODE ###

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

print(a * b // 2)
n, m, x = map(int,input().split())
a = list(map(int,input().split()))
ans1 = 0
ans2 = 0
if x == 1 or x == n or x == 2 or x == n-1:
    print(0)
else:
    for i in range(1, x):
        if a[0] == i:
            ans1 += 1
            a.pop(0)
    if len(a) != 0:
        for i in range(x, n):
            if a[0] == i:
                ans2 += 1
                a.pop(0)
    ans = min(ans1, ans2)
    print(ans)


### FIXED CODE ###

n, m, x = map(int,input().split())
a = list(map(int,input().split()))
ans1 = 0
ans2 = 0
if x == 1 or x == n:
    print(0)
else:
    for i in range(1, x):
        if len(a) != 0:
            if a[0] == i:
                ans1 += 1
                a.pop(0)
    if len(a) != 0:
        for i in range(x, n):
            if len(a) != 0:
                if a[0] == i:
                    ans2 += 1
                    a.pop(0)
    ans = min(ans1, ans2)
    print(ans)
s=input()
print(s.count(2))

### FIXED CODE ###

s=input()
print(s.count('2'))
import numpy as np
N = int(input())
A = [int(i) for i in input().split()]
B = sorted(A.copy(), reverse=True)

ans = 1
counts = np.full(B[0]+1, N)
for d in range(B[0], B[-1]//2-1, -1):
    for b in B:
        if b % d == 0:
            counts[d] -= 1
            if d != b // d:
                counts[b//d] -= 1

    if counts[d] < 2:
        ans = d
        break

if ans == 1:
    for i in range(B[-1]//2, 0, -1):
        if counts[i] < 2:
            ans = i
            break

print(ans)

### FIXED CODE ###

# 解けなかった...orz

N = int(input())
A = [int(i) for i in input().split()]

def gcd(i, j):
    if i <= 0:
        return j
    elif j <= 0:
        return i

    while i != j:
        if i < j:
            j %= i
            if j == 0: return i
        else:
            i %= j
            if i == 0: return j
    return i

# M = [0] * N
L = [0] * (N+1)
R = [0] * (N+1)
# L[0] = 0
# R[N] = 0

for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

res = max(gcd(L[i], R[i+1]) for i in range(N))
print(res)
n, w = map(int, input().split())
item = [list(map(int, input().split())) for i in range(n)]

max_v = 100005

dp = [[float('inf') * max_v] for j in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for sum_v in range(max_v):
        if sum_v - item[i][1] >= 0:
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - item[i][1]] + item[i][0])
        dp[i + 1][sum_v] = min((dp[i + 1][sum_v], dp[i][sum_v]))

for sum_v in reversed(range(max_v)):
    if dp[-1][sum_v] <= w:
        print(sum_v)
        break


### FIXED CODE ###

n, w = map(int, input().split())
item = [list(map(int, input().split())) for i in range(n)]

max_v = 100005

dp = [[float('inf')] * max_v for j in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for sum_v in range(max_v):
        if sum_v - item[i][1] >= 0:
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - item[i][1]] + item[i][0])
        dp[i + 1][sum_v] = min((dp[i + 1][sum_v], dp[i][sum_v]))

for sum_v in reversed(range(max_v)):
    if dp[-1][sum_v] <= w:
        print(sum_v)
        break
def main():
    n = int(input())
    s = list(input())

    count = 0


    if s[0] == 'W' or s[-1] == 'W':
        print(0)
        sys.exit()

    LR_list = ['' for i in range(2*n)]
    LR_list[0] = 'L'

    for i in range(1,len(LR_list)):
        if s[i] == s[i-1]:
            if LR_list[i-1] == 'R':
                LR_list[i] = 'L'
            else:
                LR_list[i] = 'R'
        else:
            if LR_list[i-1] == 'R':
                LR_list[i] = 'R'
            else:
                LR_list[i] = 'L'

    values = []

    if LR_list.count('L') != LR_list.count('R'):
        print(0)
        sys.exit()


    li = 0
    ri = 0
    for i in range(len(LR_list)):
        if i != 0:
            if LR_list[i-1] == 'L':
                li += 1
            elif LR_list[i-1] == 'R':
                ri += 1
        if LR_list[i] == 'R':
            values.append(li-ri)
    value = 1
    for i in range(len(values)):
        value = value * values[i] % (10**9+7)
    for i in range(2,n+1):
        value = value * i %(10**9+7)
    print(value)



if __name__=='__main__':
    main()

### FIXED CODE ###

import math
n = int(input())
S = input()
 
RL = [None]*2*n
 
for i in range(2*n):
    if i % 2 == 0:
        if S[i] == 'B':
            RL[i] = 'L'
        else:
            RL[i] = 'R'
 
    else:
        if S[i] == 'B':
            RL[i] = 'R'
        else:
            RL[i] = 'L'
 
if S[0] == 'W' or S[-1] == 'W':
    print(0)
    exit()
 
left = 0
count = 1
mod = 10**9 + 7
 
for check in RL:
    if check == 'L':
        left += 1
    else:
        count = count * left % mod
        left -= 1
 
    if left < 0:
        print(0)
        exit()
 
count = count * math.factorial(n) % mod
 
if left != 0:
    print(0)
else:
    print(count)
n,m=map(int,input().split())
import math

if abs(n-m) > 1:
    print(0)
else:
    print(math.factorial(n)*math.factorial(m)

### FIXED CODE ###

n,m=map(int,input().split())
import math
a=math.factorial(n)
b=math.factorial(m)
if abs(n-m) > 1:
    print(0)

elif abs(n-m)==1:

    print((a*b)%(10**9+7))
else:
    print((a*b*2)%(10**9+7))
n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])

for i in range(len(l)):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = 0
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)

### FIXED CODE ###

n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])
l.sort()

for i in range(len(l)-1):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = "1000000 1000000"
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

A,B,N = LI()
ans = 0

a = [0]*N

for x in range(1,N+1):
    # ans = max(ans,math.floor(A*x/B) - A * math.floor(x/B))
    a[x-1]=math.floor(A*x/B) - A * math.floor(x/B)

print(max(a))

### FIXED CODE ###

# 具体例を試す
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

A,B,N = LI()
# ans = 0

# a = [0]*N

# for x in range(1,N+1):
#     # ans = max(ans,math.floor(A*x/B) - A * math.floor(x/B))
#     a[x-1]=math.floor(A*x/B) - A * math.floor(x/B)

x = min(N,B-1)
ans = math.floor(A*x/B) - A * math.floor(x/B)
print(ans)
n = int(input())
ans=''
while(n>0):
     ans+=crd(ord('a')+n%26)
     n //=n
print(ans)

### FIXED CODE ###

n = int(input())
ans=''
while(n>0):
     n -= 1
     ans += chr(ord('a')+n%26)
     n //= 26
print(ans[::-1])
h,w=map(int,input().split())
s=[list(map(int,list(input()))) for i in range(h)] 

for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j]=='#':
            if s[i-1][j]=='.' and s[i][j-1]=='.' and s[i][j+1]=='.' and s[i+1][j]=='.':
                print('No')
                exit()
print('Yes')

### FIXED CODE ###

h,w=map(int,input().split())
s=[list(map(str,list(input()))) for i in range(h)] 

for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j]=='#':
            if s[i-1][j]=='.' and s[i][j-1]=='.' and s[i][j+1]=='.' and s[i+1][j]=='.':
                print('No')
                exit()
print('Yes')
import itertools as it
import collections

n, x, y = list(map(int, input().split(' ')))

dist_list = []
dist_a = dist_list.append
for i, j in it.combinations(list(range(n)), 2):
    warp_dist = abs(i - (x - 1)) + 1 + abs(j - (y - 1))
    if abs(j - i) < warp_dist:
        dist_a(abs(j - i))
    else:
        dist_a(warp_dist)

dist_c = collections.Counter(dist_list)

for i in range(1, n):
    print(dist_c[i])


### FIXED CODE ###

s = input()

s_list = [i for i in s]

if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')
import sys
n = int(input())
a_ls = list(map(int, input().split()))
hat_nperson = [0,0,1]
ans = 3
mod = 10**9+7
if a_ls[0] != 0 or a_ls[1] == 2:
    print(0)
    sys.exit()
for i in range(1,n):
    n_same = a_ls[i]
    n_choices = 0
    choice_ind = -1
    for j,person in enumerate(hat_nperson):
        if person == n_same:
            n_choices += 1
            choice_ind = j
    if choice_ind == -1:
        print(0)
        sys.exit()
    hat_nperson[choice_ind] += 1
    ans *= n_choices
    ans %= mod
print(ans%mod)

### FIXED CODE ###

import sys
n = int(input())
a_ls = list(map(int, input().split()))
hat_nperson = [0,0,1]
ans = 3
mod = 10**9+7

if a_ls[0] != 0 or (n != 1 and a_ls[1] == 2):
    print(0)
    sys.exit()

for i in range(1,n):
    n_same = a_ls[i]
    n_choices = 0
    choice_ind = -1
    for j,person in enumerate(hat_nperson):
        if person == n_same:
            n_choices += 1
            choice_ind = j
    if choice_ind == -1:
        print(0)
        sys.exit()
    hat_nperson[choice_ind] += 1
    ans *= n_choices
    ans %= mod
print(ans%mod)
in = input()

in = in.split()

N = in[0]
A = in[1]
B = in[2]


train_cost = N*A
taxi_cost  = B

if N*A > B:
    print(B)
elif:
    print(N*A)


### FIXED CODE ###

S = input()

S = S.split()

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


train_cost = N*A
taxi_cost  = B

if train_cost >= taxi_cost:
    print(taxi_cost)
else:
    print(train_cost)
S=str(input())
s=list(S)
x,y=map(int,input().split())
fora=0
side=[]
updw=[]
while s[0]=="F":
  fora+=1
  s.pop(0)
flag=1#1のとき横向き、-1のときたて向き
step=0
while s:
  if s[0]=="T":
    s.pop(0)
    if flag==-1: updw+=[step]
    else: side+=[step]
    flag=flag*(-1)
    step=0
  else:
    s.pop(0)
    step+=1
    if len(s)==0:
      if flag==-1: updw+=[step]
      else: side+=[step]
ypossi=len(side)
tpossi=len(updw)
xdp=[[0 for i in range(2*len(S)+1)] for j in range(ypossi+1)]
#dp[i][j] i個文字使ったときにj+len(s)は達成できるか
xdp[0][fora+len(S)]=1 
for i in range(ypossi):
  for j in range(2*len(S)+1):
    if j-side[i]>=0:
      if xdp[i][j-side[i]]==1:xdp[i+1][j]=1
    if j+side[i]<2*len(S)+1:
      if xdp[i][j+side[i]]==1:xdp[i+1][j]=1
        
ydp=[[0 for i in range(2*len(S)+1)] for j in range(tpossi+1)]
#dp[i][j] i個文字使ったときにj+len(s)は達成できるか
ydp[0][len(S)]=1 
for i in range(tpossi):
  for j in range(2*len(S)+1):
    if j-updw[i]>=0:
      if ydp[i][j-updw[i]]==1:ydp[i+1][j]=1
    if j+updw[i]<2*len(S)+1:
      if ydp[i][j+updw[i]]==1:ydp[i+1][j]=1
if xdp[ypossi][x+len(S)]==1 and ydp[tpossi][y+len(S)]==1:
  print("Yes")
else: print("No")

### FIXED CODE ###

S=str(input())
s=list(S)
x,y=map(int,input().split())
fora=0
side=[]
updw=[]
while s[0]=="F":
  fora+=1
  s.pop(0)
  if len(s)==0:break
flag=1#1のとき横向き、-1のときたて向き
step=0
while s:
  if s[0]=="T":
    s.pop(0)
    if step:
      if flag==-1: updw+=[step]
      else: side+=[step]
    flag=flag*(-1)
    step=0
  elif s[0]=="F":
    s.pop(0)
    step+=1
    if len(s)==0:
      if flag==-1: updw+=[step]
      else: side+=[step]
  else: break
ypossi=len(side)
tpossi=len(updw)
X=sum(side)+fora+abs(x)
Y=sum(updw)+abs(y)
xdp=[[0 for i in range(2*X+1)] for j in range(ypossi+1)]
#dp[i][j] i個文字使ったときにj+len(s)は達成できるか
xdp[0][fora+X]=1 
for i in range(ypossi):
  for j in range(2*X+1):
    if j-side[i]>=0:
      if xdp[i][j-side[i]]==1:xdp[i+1][j]=1
    if j+side[i]<2*X+1:
      if xdp[i][j+side[i]]==1:xdp[i+1][j]=1

ydp=[[0 for i in range(2*Y+1)] for j in range(tpossi+1)]
#dp[i][j] i個文字使ったときにj+len(s)は達成できるか
ydp[0][Y]=1 
for i in range(tpossi):
  for j in range(2*Y+1):
    if j-updw[i]>=0:
      if ydp[i][j-updw[i]]==1:ydp[i+1][j]=1
    if j+updw[i]<2*Y+1:
      if ydp[i][j+updw[i]]==1:ydp[i+1][j]=1
if xdp[ypossi][x+X]==1 and ydp[tpossi][y+Y]==1:
  print("Yes")
else: print("No")
#editorial参照
import sys
input = sys.stdin.read
n,*a, = map(int, input().split( ))
m = min(a)
ans = (n+m-1)//m + 4
print(ans)


### FIXED CODE ###

n=int(input())
*h,=map(int, input().split())
import numpy as np
h=np.array(h)

def rec(hh):
    if len(hh)==0:
        return 0
    if len(hh)==1:
        return hh[0]
    i=np.argmin(hh)
    res=hh[i]
    l=rec(hh[:i]-hh[i])
    r=rec(hh[i+1:]-hh[i])
    return res+l+r
print(rec(h))
if a*b%2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b = input().split()
answer = "Odd"
if (int(a)*int(b)%2) == 0:
  answer = "Even"
print(answer)
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  ans = float('inf')
  N, A, B = map(int, input().split())
  mae = [list(map(int, input().split())) for _ in range(N//2)]
  usiro = [list(map(int, input().split())) for _ in range(N-N//2)]
  mae_lis = [[float('inf')]*201 for _ in range(201)]
  for p in product([0,1],repeat=N//2):
    a,b,c = 0,0,0
    for i in range(N//2):
      if p[i]==1:
        a += mae[i][0];b += mae[i][1];c += mae[i][2]
      mae_lis[a][b] = min(mae_lis[a][b],c)
  usiro_lis = [[float('inf')]*201 for _ in range(201)]
  for p in product([0,1],repeat=N-N//2):
    a,b,c = 0,0,0
    for i in range(N//2):
      if p[i]==1:
        a += usiro[i][0];b += usiro[i][1];c += usiro[i][2]
      usiro_lis[a][b] = min(usiro_lis[a][b],c)
  for i in range(1,201):
    for j in range(1,201):
      c = mae_lis[i][j]
      if c==float('inf'):
        continue
      for k in range(1,201):
        if (i+k)*B%A!=0:
          continue
        l = (i+k)*B//A - j
        if l<=0:
          continue
        ans = min(ans,c+usiro_lis[k][l])
  return ans if ans<float('inf') else -1
print(solve())

### FIXED CODE ###

from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  ans = float('inf')
  N, A, B = map(int, input().split())
  mae = [list(map(int, input().split())) for _ in range((N+1)//2)]
  usiro = [list(map(int, input().split())) for _ in range(N-(N+1)//2)]
  if N==1:
    a,b,c = mae[0]
    if a*B==b*A:
      return c
    return -1
  mae_lis = [[float('inf')]*201 for _ in range(201)]
  mae_lis[0][0] = 0
  for p in product([0,1],repeat=(N+1)//2):
    a,b,c = 0,0,0
    for i in range((N+1)//2):
      if p[i]==1:
        a += mae[i][0];b += mae[i][1];c += mae[i][2]
    mae_lis[a][b] = min(mae_lis[a][b],c)
  usiro_lis = [[float('inf')]*201 for _ in range(201)]
  usiro_lis[0][0] = 0
  for p in product([0,1],repeat=N-(N+1)//2):
    a,b,c = 0,0,0
    for i in range(N-(N+1)//2):
      if p[i]==1:
        a += usiro[i][0];b += usiro[i][1];c += usiro[i][2]
    usiro_lis[a][b] = min(usiro_lis[a][b],c)
  for i in range(1,201):
    for j in range(1,201):
      c = mae_lis[i][j]
      if c==float('inf'):
        continue
      for k in range(201):
        if (i+k)*B%A!=0:
          continue
        l = (i+k)*B//A - j
        if l<0 or l>200 or usiro_lis[k][l]==float('inf'):
          continue
        ans = min(ans,c+usiro_lis[k][l])
  for k in range(1,201):
    if k*B%A!=0:
      continue
    l = k*B//A
    if l>200 or usiro_lis[k][l]==float('inf'):
      continue
    ans = min(ans,usiro_lis[k][l])
  return ans if ans<float('inf') else -1
print(solve())
H, W = map(int, input().split())
h, w = map(int, input().split())
ans = h * W + w * H - h * w 
print(ans)H, W = map(int, input().split())
h, w = map(int, input().split())
ans = H * W - (h * W + w * H - h * w) 
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
h, w = map(int, input().split())
ans = H * W - (h * W + w * H - h * w) 
print(ans)
X, Y, Z = map(int, input().split())

print(Z + " " + X + " " + Y)

### FIXED CODE ###

X, Y, Z = map(int, input().split())

x = str(X)
y = str(Y)
z = str(Z)
print(z + " " + x + " " + y)
def ok(s: str): str:
    char_count = {}
    for c of s:
      if c not in char_count:
        char_count[c] = 0
      if c in char_count.keys():
        chars[c] += 1
    
    yes = all([count == 2 for count in char_count.values()])
    if yes:
      return 'Yes'
    else:
      return 'No'


### FIXED CODE ###

def ok(s: str) -> str:
    char_count = {}
    for c in s:
      if c not in char_count:
        char_count[c] = 0
      if c in char_count.keys():
        char_count[c] += 1
    
    return all([count == 2 for count in char_count.values()])

numbers_str = input()
result = ok([c for c in numbers_str])
if result:
  print('Yes')
else:
  print('No')
route_num, limit = map(int, input().split(' '))

costs = []
spends = []
for i in range(route_num):
    cost, spend = map(int, input().split(' '))
    costs.append(cost)
    spends.append(spend)

min_cost = 2000
for cost, spend in zip(costs, spends):
    if spend <= limit and cost < min_cost:
        min_cost = cost

if min_cost == 2000:
    print("TLE")

else:
    print(min_cost)


### FIXED CODE ###

pattern = int(input())

if pattern == 1:
    print("Hello World")
elif pattern == 2:
    a = int(input())
    b = int(input())

    print(a + b)
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
print(a,b)
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j:j+m] == b[0] and a[i+1][j:j+m] == b[1]:
            flag = 1
print("Yes" if flag == 1 else "No")

### FIXED CODE ###

n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
r = any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print("Yes" if r else "No")