n = int(input())
F = [[int(i) for i in input().split()] for i in range(n)]
P = [[int(i) for i in input().split()] for i in range(n)]

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return 0
    
ans = -10 ** 10
for i in range(1, 2 ** 10):
    for j in range(10):
        A[j] = f(i // (2 ** (10 - i)))

    temp = 0
    for s in range(n):
        count = 0
        for t in range(10):
            if F[s][t] == 1 and A[t] == 1:
                count += 1
        temp += P[s][count]
    ans = max(ans, temp)
        
print(ans)