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)]

ans = (-1)*float('inf')

for i in range(1,1024):
    tmp = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if ((i>>k)&1)&F[j][k]:
                count+=1
        tmp+=P[j][count]
    ans=max(ans,tmp)

print(ans)