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