import itertools
N = int(input())
F = [list(map(int,input().split())) for _ in range(N)]
F.insert(0,[0])
P = [list(map(int,input().split())) for _ in range(N)]
P.insert(0,[0])
cmax = 0
for x in itertools.product((0,1),repeat=10):
    cnt = 0
    for i in range(1,N+1):
        c = 0
        for j in range(10):
            if x[j]==1 and F[i][j]==1:
                c += 1
        cnt += P[i][c]
    cmax = max(cmax,cnt)
print(cmax)