f=lambda:[list(map(int,input().split())) for _ in range(n)]

n=int(eval(input()))

llf,llp=f(),f()

a=-10**9

import itertools as it

for t in it.product([0,1],repeat=10):

  if sum(t):

    lc=[sum(t[i]*lf[i] for i in range(10)) for lf in llf]

    a=max(a,sum(llp[i][lc[i]] for i in range(n)))

print(a)
I=input;R=range;n=int(I())

lf=[int(I()[::2],2) for _ in R(n)]

lp=[list(map(int,I().split())) for _ in R(n)]

print((max(sum(p[bin(i&f).count('1')] for f,p in zip(lf,lp)) for i in R(1,1024))))
f = lambda: [list(map(int, input().split())) for _ in range(n)]
n = int(eval(input()))
llf, llp = f(), f()
a = -(10**9)
import itertools as it

for t in it.product([0, 1], repeat=10):
    if sum(t):
        lc = [sum(t[i] * lf[i] for i in range(10)) for lf in llf]
        a = max(a, sum(llp[i][lc[i]] for i in range(n)))
print(a)

I = input
R = range
n = int(I())
lf = [int(I()[::2], 2) for _ in R(n)]
lp = [list(map(int, I().split())) for _ in R(n)]
print((max(sum(p[bin(i & f).count("1")] for f, p in zip(lf, lp)) for i in R(1, 1024))))

-f = lambda: [list(map(int, input().split())) for _ in range(n)] -n = int(eval(input())) -llf, llp = f(), f() -a = -(10**9) -import itertools as it - -for t in it.product([0, 1], repeat=10): -    if sum(t): -        lc = [sum(t[i] * lf[i] for i in range(10)) for lf in llf] -        a = max(a, sum(llp[i][lc[i]] for i in range(n))) -print(a) +I = input +R = range +n = int(I()) +lf = [int(I()[::2], 2) for _ in R(n)] +lp = [list(map(int, I().split())) for _ in R(n)] +print((max(sum(p[bin(i & f).count("1")] for f, p in zip(lf, lp)) for i in R(1, 1024))))