N = int(raw_input())
lisday = []
lisp= []
last = []
for num in xrange(N):
  lisday.append( map(int,raw_input().split()) )
for num in xrange(N):
  lisp.append( map(int,raw_input().split()) ) 
for n in xrange(1,1024):
	n2 = format(n,"010b")
	lissum =[]
	for numb in xrange(N):
		check = map(int,list(str(n2)))
		count = 0
		for select in xrange(10):
			if check[select] == 1 and lisday[numb][select] == 1:
				count += 1
		lissum.append(lisp[numb][count])
	last.append(sum(lissum))
print max(last)
