import numpy as np
import heapq as hq
N = int(input())
F = np.array([[int(x) for x in input().split()] for _ in range(N)])
P = np.array([[int(x) for x in input().split()] for _ in range(N)])

Profit = 10e-20
for i in range(1,2**10): #bit全探索
    Open = np.array([int(x) for x in format(i, '010b')]) #2進数をベクトルに変換
    prf = 0
    for f, p in zip(F, P):
        cnt = np.dot(Open, f)
        prf += p[cnt]
    Profit = max(Profit, prf)
print(Profit)
        