#abc080c

n=int(raw_input())
f=[map(int,raw_input().split()) for i in xrange(n)]
p=[map(int,raw_input().split()) for i in xrange(n)]
res=-float('inf')
for i in xrange(1,1024):
 temp=0
 for j in xrange(n):
  cnt=0
  for k in xrange(10):
   cnt+=int(i>>k&1 and f[j][k])
  temp+=p[j][cnt]
 res=max(temp,res)
print res
