
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())))

is_open=[]
def count_score(is_open,N,F,P):
    is_open_copy=list(is_open)
    if len(is_open_copy)==10:
        count_N = [0 for i in range(N)]
        for i in range(N):
            for j in range(10):
                if is_open[j] and F[i][j]==1:
                    count_N[i]+=1
        score = 0
        for i in range(N):
            score+=P[i][count_N[i]]
        return score
    return max(count_score(is_open_copy+[True],N,F,P),count_score(is_open_copy+[False],N,F,P))

print(count_score(is_open,N,F,P))