f=lambda:[list(map(int,input().split())) for _ in range(n)]
n=int(input())
llf,llp=f(),f()
a=-10**9
import itertools as it
for t in it.product([0,1],repeat=10):
  if sum(t):
    lc=[sum(t[i]*lf[i] for i in range(10)) for lf in llf]
    a=max(a,sum(llp[i][lc[i]] for i in range(n)))
print(a)