n = int(input())
f = [[int(x) for x in input().split()] for i in range(n)]
p = [[int(x) for x in input().split()] for i in range(n)]
ans=-(10**8)
for i in range(1,2**10):
  d, t, b={j:0 for j in range(n)}, 0, format(i, "010b")
  for j in range(n):
    for k in range(10):
      if (i>>k)%2&f[j][k]==1: d[j]+=1
    t+=p[j][d[j]]
  if ans<t: ans=t
print(ans)