n = int(input())
f = []
for _ in [0]*n:
  f += [list(map(int,input().split()))]
p = []
for _ in [0]*n:
  p += [list(map(int,input().split()))]
m = -10000001*n
for x in range(1,1024):
  k = 0
  s = format(x,'010b')
  for t in range(n):
    k += p[t][sum([int(s[i])*f[t][i] for i in range(10)])]
  m = max(m,k)
print(m)  