n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]
pls=[]
for i in range(1,2**10):
  bin=format(i,"b").zfill(10)
  pf=0
  for x in range(n):
    cnt=0
    for j in range(10):
      if int(bin[j])==f[x][j]==1:
        cnt+=1
    pf+=p[x][cnt]
  pls.append(pf)
print(max(pls))