N=int(input())
F=[list(map(int,input().split())) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]

l=[0]*(2**10-1)
for i in range(1,2**10):
  op=list(map(int,list(bin(i)[2:].zfill(10))))
  for n in range(N):
    c=0
    for o in range(10):
      if op[o]==1 and F[n][o]==1:
        c+=1
    l[i-1]+=P[n][c]
    
print(max(l))