import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = [list(map(int,readline().split())) for i in range(n)]

lst2 = [list(map(int,readline().split())) for i in range(n)]

#曜日、時刻にどの店が営業しているかを埋め込む
lst3 = [[] for _ in range(10)]
for i in range(n):
    for j in range(10):
        if lst1[i][j] == 1:
            lst3[j].append(i)

#ビット全探索
def bit_search(lst):
    keta = len(lst)
    bit_lst = []
    for i in range(2**keta):
        sub = [0]*10
        for j in range(keta):
            if ((i>>j) &1):
                for k in lst3[j]:
                    sub[k] += 1
        bit_lst.append(sub)
    return bit_lst


dummy = [0]*(10)
all_lst = bit_search(dummy)

ans = -10**9
for i in all_lst[1:]:
    res = 0
    for j in range(n):
        res += lst2[j][i[j]]
    ans = max(res,ans)

print(ans)