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

ans = -(10**8)
for i in range(2**10):
    one_or_zero = [0] * 10
    for j in range(10):
        if ((i >> j) & 1):
            one_or_zero[10 - 1 - j] = 1
    if 1 not in one_or_zero:
        pass
    else:
        tmp_ans = 0
        for m in range(N):
            count = 0
            for k in range(10):
                if F[m][k] == 1 and one_or_zero[k] == 1:
                    count += 1
            tmp_ans += P[m][count]
        if tmp_ans > ans:
            ans = tmp_ans

print(ans)