from itertools import product
import numpy as np
N = int(input())
F = np.array([list(map(int, input().split())) for _ in range(N)])
P = np.array([list(map(int, input().split())) for _ in range(N)])
M = np.array([0]*1024)
for i, f in enumerate(product([0, 1], repeat=10)) :
    if f == [0]*10 : continue
    f = np.array(f)
    a = np.sum(F*f, axis=1)
    M[i] = sum([l[i] for l, i in zip(P, a)])
print(np.max(M))