n = int(eval(input()))

arr = [list(map(int, input().split())) for i in range(n)]

arm = [list(map(int, input().split())) for j in range(n)]



ans = -9999999999

for item in range(1, 1024):

    fund = 0

    for i in range(n):

        cou = 0

        for x in range(10):

            if (item >> x) % 2 == 1 and arr[i][x] == 1:

                cou += 1

        fund += arm[i][cou]

    ans = max(ans, fund)



print(ans)
def solve():

    n = int(eval(input()))

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

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



    ans = -9999999999



    for a in range(1, 1 << 10):

        res = 0

        for i in range(n):

            cnt = 0

            for x in range(10):

                if (a >> x) % 2 == 1 and oc[i][x] == 1:

                    cnt += 1

            res += prof[i][cnt]

        ans = max(ans, res)

    print(ans)





solve()

n = int(eval(input()))
arr = [list(map(int, input().split())) for i in range(n)]
arm = [list(map(int, input().split())) for j in range(n)]
ans = -9999999999
for item in range(1, 1024):
    fund = 0
    for i in range(n):
        cou = 0
        for x in range(10):
            if (item >> x) % 2 == 1 and arr[i][x] == 1:
                cou += 1
        fund += arm[i][cou]
    ans = max(ans, fund)
print(ans)

def solve():
    n = int(eval(input()))
    oc = [list(map(int, input().split())) for _ in range(n)]
    prof = [list(map(int, input().split())) for _ in range(n)]
    ans = -9999999999
    for a in range(1, 1 << 10):
        res = 0
        for i in range(n):
            cnt = 0
            for x in range(10):
                if (a >> x) % 2 == 1 and oc[i][x] == 1:
                    cnt += 1
            res += prof[i][cnt]
        ans = max(ans, res)
    print(ans)


solve()

-n = int(eval(input())) -arr = [list(map(int, input().split())) for i in range(n)] -arm = [list(map(int, input().split())) for j in range(n)] -ans = -9999999999 -for item in range(1, 1024): -    fund = 0 -    for i in range(n): -        cou = 0 -        for x in range(10): -            if (item >> x) % 2 == 1 and arr[i][x] == 1: -                cou += 1 -        fund += arm[i][cou] -    ans = max(ans, fund) -print(ans) +def solve(): +    n = int(eval(input())) +    oc = [list(map(int, input().split())) for _ in range(n)] +    prof = [list(map(int, input().split())) for _ in range(n)] +    ans = -9999999999 +    for a in range(1, 1 << 10): +        res = 0 +        for i in range(n): +            cnt = 0 +            for x in range(10): +                if (a >> x) % 2 == 1 and oc[i][x] == 1: +                    cnt += 1 +            res += prof[i][cnt] +        ans = max(ans, res) +    print(ans) + + +solve()