N=int(input())
F=[[int(s) for s in input().split()] for i in range(N)]
P=[[int(s) for s in input().split()] for i in range(N)]
def bi(num):
  val_ls=[0 for _ in range(10)]
  for bi_i in range(10):
    if (2**bi_i)&num>0:
      val_ls[bi_i]=1
  return val_ls
def ri(bi_ls):
  val_ri=0
  for ri_i in range(N):
    val=0
    for j in range(10):
      if bi_ls[j]==F[ri_i][j] and bi_ls[j]==1:
        val+=1
    val_ri+=P[ri_i][val]
  return val_ri
print(max([ri(bi(i)) for i in range(1,1023)]))
      
  