def calculate():
    global maxv
    if sum(ans) == 0:
        return
    score = 0
    for i in range(N):
        num = 0
        for j in range(10):
            if ans[j] == 0:
                continue
            num = num + [0, 1][ans[j] == F[i][j]]
        score += P[i][num]
    maxv = max(maxv, score)

def dfs(pos):
    if pos == 10:
        calculate()
        return
    ans[pos] = 0
    dfs(pos+1)
    ans[pos] = 1
    dfs(pos+1)

N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

pos = 0
ans = [0] * 10
maxv = -1000000
dfs(pos)
print(maxv)
