n=int(input())
F=[list(map(int,input().split())) for i in range(n)]
P=[list(map(int,input().split())) for i in range(n)]
ans=-10**9
for i in range(1,2**10):
  tmp=0
  for j in range(n):
    cnt=0
    f=F[j]
    p=P[j]
    for k in range(10):
      if (i>>k)&1:
        cnt+= 1 if f[k] else 0
    tmp+=p[cnt]
  ans=max(ans,tmp)
print(ans)