N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]

ans = -float('inf')
for b in range(1,2**10):
    tmp = 0
    for i in range(N):
        c = 0
        for k in range(10):
            if b&(1<<k) and F[i][k]:
                c += 1
        tmp += P[i][c]
    ans = max(ans,tmp)
print(ans)
