# https://atcoder.jp/contests/abc080/tasks/abc080_c
# 普通にbit全探索では？

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

bitlen = 10


def ret_score(n: int):
    # 営業時間かぶり計算
    C = []
    for i in range(N):  # Nでiter
        cnt = 0
        for bit in range(bitlen):  # 桁とFを対応
            if ((n >> bit) & 1) and F[i][bit]:  # もし1その桁で1なら
                cnt += 1
        C.append(cnt)

    # スコア計算
    ret = 0
    for i, c in enumerate(C):
        ret += P[i][c]
    return ret


ans = -10**9 + 1
for n in range(1, 1 << bitlen):
    ans = max(ans, ret_score(n))
print(ans)
