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

ans = -1000000000

for i in range(1,1024):
    F0 = [0]*10
    i_temp = i
    for j in range(10):
        F0[j] = i_temp%2
        i_temp = int(i_temp/2)
    
    c = [0]*10
    for j in range(10):
        if F0[j] == 1:
            for k in range(N):
                c[k] += F[k][j]
    
    ans_temp = 0
    for j in range(N):
        ans_temp += P[j][c[j]]
    ans = max(ans, ans_temp)

print(ans)