n = int(input())
flist = []
for _ in range(n):
    flist.append([int(f) for f in input().split()])

plist = []
for _ in range(n):
    plist.append([int(p) for p in input().split()])


def commonSum(a_l, b_l):
    """共通要素を返す"""
    cnt = 0
    for a, b in zip(a_l, b_l):
        if a == b and a == 1:
            cnt += 1
    return cnt


# 初期値
profit = -10**7
for open in range(1, 2**10):
    openlist = [int(i) for i in format(open, 'b').zfill(10)]

    # 各店との利益を求める
    prof = 0
    for i in range(n):
        common = commonSum(flist[i], openlist)
        prof += plist[i][common]
    profit = max(profit, prof)
print(profit)
