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=-float("inf")
for i in range(1,1<<10):
    score=0
    for j in range(n):
        cnt=0
        for k in range(10):
            if i&(1<<k) and f[j][k]==1:
                cnt+=1
        score+=p[j][cnt]
    ans=max(ans,score)
print(ans)

