from itertools import product
N=int(input())
F=[list(map(int, input().split())) for i in range(N)]
P=[list(map(int, input().split())) for i in range(N)]
l=list(product(range(2),repeat=10))
del l[0]
a=-10**7
for i in range(1023):
    t=0
    for j in range(N):
        c=0
        for k in range(10):
            c+=F[j][k] and l[i][k]
        t+=P[j][c]
    if t>a:
        a=t
print(a)