N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for j in range(N)]  
ma = -9999999999  
for i in range(1, 2**10):
    su = 0
    for j in range(N):
        count = 0
        for k in range(10):
            if ((i >> k)&1) == 1 and F[j][k] == 1:
                count += 1
        su += P[j][count]
    ma = max(ma, su)  
print(max)