n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
inf=float("inf")
ans=-inf
for i in range(1,2**10):
    cc=0
    for k in range(n):
        c=0
        for j in range(10):
            if ((i>>j)&1) and f[k][j]:
                c+=1
        cc+=p[k][c]
    ans=max(ans,cc)
print(ans)
