n=int(input())
f=[]
p=[]
for i in range(0,n):
  temp=list(map(int,input().split()))
  f.append(temp)
for i in range(0,n):
  temp=list(map(int,input().split()))
  p.append(temp)
ans=-99999999
for i in range(1,2**10):
  temp=0
  for j in range(0,n):
    count=0
    for k in range(0,10):
      if (i<<j)&1 and f[j][k]==1:        
        count=count+1
    temp=temp+p[j][count]
  ans=max(ans,temp)
print(ans)
