import sys
import math
from operator import add

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(' '))))
maxprofit = -100000
for i in range(1, 1024):
    binstr = bin(i) 
    original = list(map(int, binstr[2:]))
    original = [0]*(10-len(original)) + original
    profit = 0
    for j in range(N):
        s = [a+b for (a, b) in zip(original, F[j])]
        dup = len([a for a in s if a == 2])
        profit += P[j][dup]
    if maxprofit < profit:
        maxprofit = profit
print(maxprofit)