# bit全探索

N = int(eval(input()))

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

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

ans = -float('inf')

for i in range(2**10):

    if i == 0: # 全く営業しないパターン

        continue

    profit = 0

    pattern = [0]*10

    for j in range(10):

        if 1 << j & i:

            pattern[j] = 1

    #print(pattern)



    for k in range(N):

        #l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])

        l = 0

        for m in range(10):

            if pattern[m] == F[k][m] == 1:

                l += 1



        #print(l)

        profit += P[k][l]

    ans = max(ans,profit)

print(ans)







# bit全探索

N = int(eval(input()))

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

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

ans = -float('inf')

for i in range(2**10):

    if i == 0: # 全く営業しないパターン

        continue

    profit = 0

    pattern = [0]*10

    for j in range(10):

        if 1 << j & i:

            pattern[j] = 1

    #print(pattern)



    for k in range(N):

        l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])

        # l = 0

        # for m in range(10):

        #     if pattern[m] == F[k][m] == 1:

        #         l += 1



        #print(l)

        profit += P[k][l]

    ans = max(ans,profit)

print(ans)







# bit全探索
N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float("inf")
for i in range(2**10):
    if i == 0:  # 全く営業しないパターン
        continue
    profit = 0
    pattern = [0] * 10
    for j in range(10):
        if 1 << j & i:
            pattern[j] = 1
    # print(pattern)
    for k in range(N):
        # l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])
        l = 0
        for m in range(10):
            if pattern[m] == F[k][m] == 1:
                l += 1
        # print(l)
        profit += P[k][l]
    ans = max(ans, profit)
print(ans)

# bit全探索
N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float("inf")
for i in range(2**10):
    if i == 0:  # 全く営業しないパターン
        continue
    profit = 0
    pattern = [0] * 10
    for j in range(10):
        if 1 << j & i:
            pattern[j] = 1
    # print(pattern)
    for k in range(N):
        l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])
        # l = 0
        # for m in range(10):
        #     if pattern[m] == F[k][m] == 1:
        #         l += 1
        # print(l)
        profit += P[k][l]
    ans = max(ans, profit)
print(ans)

-        # l = sum([pattern[m] == F[k][m] == 1 for m in range(10)]) -        l = 0 -        for m in range(10): -            if pattern[m] == F[k][m] == 1: -                l += 1 +        l = sum([pattern[m] == F[k][m] == 1 for m in range(10)]) +        # l = 0 +        # for m in range(10): +        #     if pattern[m] == F[k][m] == 1: +        #         l += 1