n = int(input())
flst = []
for _ in range(n):
  flst.append([int(i) for i in input().split()])
plst = []
for _ in range(n):
  plst.append([int(i) for i in input().split()])
m = - 1 << 30
for i in range(1, 1 << 10):
  r = 0
  for j in range(n):
    c = 0
    for k in range(10):
      if (i >> k & 1) & flst[j][k]:
        c += 1
    r += plst[j][c]
  m = max(m, r)
print(m)
