n=int(input())
f=[0]*n
for i in range(n):
  x=list(map(int,input().split()))
  for j in range(len(x)):
    if x[j]==1:
      f[i]+=1<<j
  
p=[[0 for j in range(10)] for i in range(n)]

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

ans=10**8*(-1)-1
for i in range(1,2**10):
  pro=0
  for j in range(len(f)):
    open=0
    for k in range(10):
      if (i>>k)&1==1 and (f[j]>>k)&1==1:
        open+=1
    pro+=p[j][open]
  if ans<pro:
    ans=pro
print(ans)