def solver():
    import itertools
    N = int(input())

    # implements
    Fs = [list(map(int, input().split())) for n in range(N)]
    Ps = [list(map(int, input().split())) for n in range(N)]

    # joisino姉がお店を開く全組み合わせ
    Xs = itertools.product([0,1], repeat=10)
    next(Xs) # すべて0を除く

    ans = (-10**7)*10
    for x in Xs:
        profit = 0
        for n in range(N):
            c = 0
            for a, b in zip(x, Fs[n]):
                if a == b == 1:
                    c += 1
            profit += Ps[n][c]
        ans = max(ans, profit)
    print(ans)


if __name__ == "__main__":
    solver()
