N = int(input())
F = []
P = []
maxl = 0
M = [0,0,0,0,0,0,0,0,0,0]
for i in range(N):
  L = list(map(int,input().split()))
  for j in range(10):
    if M[j]==0 and L[j]!=0:
      M[j]+=1
  F.append(L)
for i in range(N):
  L = list(map(int,input().split()))
  maxl = min(maxl,min(L))
  P.append(L)
k=1
K = [0,0,0,0,0,0,0,0,0,0]
while k<1024:
  maxll=0
  d = k
  for i in range(10):
    K[i] = d%2
    d = d//2
  k+=1
  if K!=M:
    for Ni in range(N):
      count=0
      for i in range(10):
        if F[Ni][i] and K[i]:
          count+=1
      maxll+=P[Ni][count]
    maxl = max(maxll,maxl)
print(maxl)