n=int(input());f,p=[],[];ans=""
for _ in range(n):f.append(list(map(int,input().split())))
for _ in range(n):p.append(list(map(int,input().split())))
for i in range(1,2**10):
  s=bin(i)[2:].zfill(10);a=0
  for j in range(n):
    m=0
    for h in range(10):
      if s[h]=="1":m+=f[j][h]
    a+=p[j][m]
  ans=(a if ans==""else max(ans,a))
print(ans)