N = int(input())
F = []

for _ in range(N):
    F.append(list(map(int, input().split())))

P = []

for _ in range(N):
    P.append(list(map(int, input().split())))

c = [0] * 10
ans = - float('inf')
tmp = 0

for i in range(1, 1024):
    ii = format(i, 'b')
    ii = str(ii)
    ii = ii.zfill(10)
    ii = list(ii)
    for j in range(N):
        for k in range(10):
            if str(F[j][k]) == ii[k] and ii[k] == '1':
                c[j] += 1
    for j in range(N):
        tmp += P[j][c[j]]
    if tmp > ans:
        ans = tmp
    tmp = 0
    c = [0] * 10

print(ans)