n = int(input())
# f=[list(map(int,input().split())) for _ in range(n)]
f=[list(input().split()) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
ans=-1000000007
for mask in range(1,1<<10):
    tmp=0
    for i in range(n):
        count=0
        for j in bin(mask&int(str("".join(f[i])),2))[2:]:
            count+=1
        tmp+=p[i][count]
    ans=max(ans,tmp)
print(ans)