# coding:utf-8
inp = input()
N = int(inp)

eigyo = []

b = []
Ci = []
for i in range(N):
    N_ = list(map(int, input().split()))
    eigyo.append(N_)
    Ci.append(sum(N_))

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


ans = 0
a = list(map(lambda x: x*0, list(range(10))))
count = 0

def func():
    #score = 0
    global count
    count += 1
    #print(count, a)
    cc = 0
    for i in range(N):
        count_c = 0
        for j,element in enumerate(eigyo[N]):
            if element==a[j]:
                count_c += 1
        cc += P[i][count_c]

    global ans
    ans = max(ans, cc)
            
    #ans = max(ans, score)

def dfs(pos):
    if pos==10:
        func()
        return
    a[pos] = 0
    dfs(pos+1)
    a[pos] = 1
    dfs(pos+1)


dfs(0)
print(ans)
