N=int(input())
F=[list(map(int,input().split())) for _ in range(N)] #0-9
P=[list(map(int,input().split())) for _ in range(N)] #0-10

INF=10**9
ans=-INF

for i in range(1,2**10):
    tmp=[0]*10
    tmpans=0
    for j in range(0,10):
        bit=i>>j&1
        for n in range(N):
            tmp[n]+=F[n][j]*bit
    for n in range(N):
        tmpans+=P[n][tmp[n]]

    ans=max(ans,tmpans)

print(ans)