# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())
F = []
for i in range(n):
    f = [int(i) for i in input().split()]
    F.append(f)



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

F = np.array(F)
P = np.array(P)


def cal_val(shop_num,open_time):
    open_time = int(np.dot(F[shop_num],open_time.T))
    # print(open_time)
    return P[shop_num,open_time]

def to2digit(i):
    open_time = np.zeros([10])
    for count in range(10):
        if i%2==1:
            open_time[count] = 1
        i = i//2
    return open_time



values = []

for i in range(1,2**10-1):
    open_time = np.zeros([10])
    for j in range(10):
        if i%2==1:
            open_time[j] = 1
        i = i//2
    value = 0
    for shop_num in range(n):
        value += cal_val(shop_num,open_time)
    values.append(value)

print(max(values))
