N = int(input())
F = []
for i in range(N):
  F.append(list(map(int, input().split())))
  
P = []
for i in range(N):
  P.append(list(map(int, input().split())))
  
ma = 0

for i in range(1, 1024):
  t = i
  x = []
  for j in range(10):
    x.append(t % 2)
    t //= 2
  wa = 0
  for j in range(N):
    cnt = 0
    for k in range(10):
      if x[k] == 1 and F[j][k] == 1:
        cnt += 1
    wa += P[j][cnt]
    
  if ma < wa:
    ma = wa
print(ma)
        