N = input()
F = [map(int, raw_input().split()) for i in range(N)]
P = [map(int, raw_input().split()) for i in range(N)]
M = 10
ans = -10**10
for mask in range(1, 2**M):
    m = [int((mask & (2**i)) > 0) for i in range(M)]
    ok = False
    sales = 0
    for i in range(N):
        cnt = 0
        for j in range(M):
            if m[j] + F[i][j] == 2:
                ok = True
                cnt += 1
        sales += P[i][cnt]
    if ok:
        ans = max(ans, sales)
print ans