N=int(raw_input())

f=[]
for _ in range(N):
  f.append(map(int,raw_input().split(' ')))

p=[]
for _ in range(N):
  p.append(map(int,raw_input().split(' ')))

s=float('-inf')
for t in range(1,1024):
  l=map(int,list(bin(t)[2:].zfill(10)))
  tmp=0
  for i in range(N):
    c=0
    for t in range(10):
      if l[t]==0:
        continue
      if f[i][t]:
        c+=1

    tmp+=p[i][c]

  if tmp>s:
    s=tmp
    
print s
