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=-float("inf")
for i in range(1,1 << 10):
  res=0
  for n in range(N):
    count=0
    for j in range(10):
      if i & F[n][j]<<j: count+=1
    res+=P[n][count]
  ans=max(res,ans)
print(ans)