import itertools
N = int(input())
F = []
for i in range(N):
    F_next = input().split()
    F_next = [int(i) for i in F_next]
    F.append(F_next)
P = []
for i in range(N):
    P_next = input().split()
    P_next = [int(i) for i in P_next]
    P.append(P_next)

#営業する時間を入力してそれぞれのお店との被る日数を出力
def count_number(shop):
    count = [0]*N
    for i in range(N):
        for j in range(10):
            if(shop[j]==1 and F[i][j]==1):
                count[i] = count[i]+1
    return (count)
#お店と被る日数を入力して利益を出力
def benefit(count):
    #一日も店を開かない日があってはダメなので利益を最小にしておく
    if(sum(count)==0):
        return(-100000000)
    bene_sum = 0
    for i in range(N):
        bene_sum = bene_sum + P[i][count[i]]
    return(bene_sum)

bene = []
for shop in itertools.product(range(2),repeat = 10):
    bene_next = benefit(count_number(shop))
    bene.append(bene_next)
print(max(bene))