n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for j in range(n)]

l=[]
for k in range(1,1024):
  l.append(format(k,'010b'))

L=[]
for m in range(1023):
  C=0
  for q in range(n):
    c=0
    for r in range(10):
      if f[q][r]*int(l[m][r])==1:
        c+=1
    C+=p[q][c]
  L.append(C)
print(max(L))