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

# # パターンAとパターンBがどれだけ一致しているかを表す函数
def score(_bin, F, P):
    score = 0
    for j, f in enumerate(F):
        hit_counter = 0
        for i in range(10):
            if _bin>>i & 1 and f[i] == 1:
                hit_counter += 1
        score += P[j][hit_counter]
    return score

max_score = -1000
for i in range(1,1<<10):
    max_score = max(max_score, score(i, F, P))

print(max_score)
