import numpy as np

N = int(eval(input()))

F = [[int(x) for x in input().split()] for _ in range(N)]

P = [[int(x) for x in input().split()] for _ in range(N)]



import itertools

answer = -(10 ** 18)

for a in itertools.product([0,1], repeat = 10):

  if sum(a) == 0:

    continue

  profit = 0

  for shop in range(N):

    profit += P[shop][sum(a[i]*F[shop][i] for i in range(10))]

  if answer < profit:

    answer = profit



print(answer)

  

n=int(eval(input()))

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

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

ma=-10000000000000

for i in range(1,2**10):

    check=[0]*n

    for j in range(10):

        if (i>>j) & 1:

            for k in range(n):

                check[k]+=f[k][j]

    ma_sub=0

    for i in range(n):

        ma_sub+=p[i][check[i]]

    ma=max(ma,ma_sub)

print(ma)
import numpy as np

N = int(eval(input()))
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]
import itertools

answer = -(10**18)
for a in itertools.product([0, 1], repeat=10):
    if sum(a) == 0:
        continue
    profit = 0
    for shop in range(N):
        profit += P[shop][sum(a[i] * F[shop][i] for i in range(10))]
    if answer < profit:
        answer = profit
print(answer)

n = int(eval(input()))
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]
ma = -10000000000000
for i in range(1, 2**10):
    check = [0] * n
    for j in range(10):
        if (i >> j) & 1:
            for k in range(n):
                check[k] += f[k][j]
    ma_sub = 0
    for i in range(n):
        ma_sub += p[i][check[i]]
    ma = max(ma, ma_sub)
print(ma)

-import numpy as np - -N = int(eval(input())) -F = [[int(x) for x in input().split()] for _ in range(N)] -P = [[int(x) for x in input().split()] for _ in range(N)] -import itertools - -answer = -(10**18) -for a in itertools.product([0, 1], repeat=10): -    if sum(a) == 0: -        continue -    profit = 0 -    for shop in range(N): -        profit += P[shop][sum(a[i] * F[shop][i] for i in range(10))] -    if answer < profit: -        answer = profit -print(answer) +n = int(eval(input())) +f = [list(map(int, input().split())) for i in range(n)] +p = [list(map(int, input().split())) for i in range(n)] +ma = -10000000000000 +for i in range(1, 2**10): +    check = [0] * n +    for j in range(10): +        if (i >> j) & 1: +            for k in range(n): +                check[k] += f[k][j] +    ma_sub = 0 +    for i in range(n): +        ma_sub += p[i][check[i]] +    ma = max(ma, ma_sub) +print(ma)