N=int(input())
F=[[0]*10 for _ in range(N)]
P=[[0]*10 for _ in range(N)]
for i in range(N):
    F[i]=list(map(int,input().split()))
for i in range(N):
    P[i]=list(map(int,input().split()))
i=1
ans=P[0][1]
cnt=0
while i<=int('1111111111',2):
    tmp_ans=0
    bin_str=format(i,'10b')
    for j in range(N):
        cnt=0
        for k in range(10):
            if bin_str[k]=='1' and F[j][k]==1:
                cnt+=1
        tmp_ans+=P[j][cnt]
    if tmp_ans>ans:
        ans=tmp_ans
    i+=1
print(ans)