# coding:utf-8



INF = float('inf')





def inpl(): return list(map(int, input().split()))





N = int(eval(input()))



F = [inpl() for _ in range(N)]

P = [inpl() for _ in range(N)]



ans = -INF

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



    score = 0

    for shop in range(N):



        both_open = 0

        for period in range(10):

            if i >> period & F[shop][period] == 1:

                both_open += 1



        score += P[shop][both_open]



    ans = max(ans, score)



print(ans)
# coding:utf-8



import sys



INF = float('inf')

MOD = 10 ** 9 + 7



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]

def LS(): return sys.stdin.readline().split()

def II(): return int(sys.stdin.readline())

def SI(): return eval(input())





n = II()

F = [LI() for _ in range(n)]

P = [LI() for _ in range(n)]



ans = -INF

for bit in range(1, 1024):

    profit = 0

    for shop in range(n):

        cnt = 0

        for shift in range(10):

            if not bit >> shift & 1:

                continue



            if F[shop][shift]:

                cnt += 1



        profit += P[shop][cnt]



    ans = max(ans, profit)



print(ans)

# coding:utf-8
INF = float("inf")


def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
F = [inpl() for _ in range(N)]
P = [inpl() for _ in range(N)]
ans = -INF
for i in range(1, 1 << 10):
    score = 0
    for shop in range(N):
        both_open = 0
        for period in range(10):
            if i >> period & F[shop][period] == 1:
                both_open += 1
        score += P[shop][both_open]
    ans = max(ans, score)
print(ans)

# coding:utf-8
import sys

INF = float("inf")
MOD = 10**9 + 7


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def LS():
    return sys.stdin.readline().split()


def II():
    return int(sys.stdin.readline())


def SI():
    return eval(input())


n = II()
F = [LI() for _ in range(n)]
P = [LI() for _ in range(n)]
ans = -INF
for bit in range(1, 1024):
    profit = 0
    for shop in range(n):
        cnt = 0
        for shift in range(10):
            if not bit >> shift & 1:
                continue
            if F[shop][shift]:
                cnt += 1
        profit += P[shop][cnt]
    ans = max(ans, profit)
print(ans)

+import sys + +MOD = 10**9 + 7 -def inpl(): -    return list(map(int, input().split())) +def LI(): +    return [int(x) for x in sys.stdin.readline().split()] -N = int(eval(input())) -F = [inpl() for _ in range(N)] -P = [inpl() for _ in range(N)] +def LI_(): +    return [int(x) - 1 for x in sys.stdin.readline().split()] + + +def LS(): +    return sys.stdin.readline().split() + + +def II(): +    return int(sys.stdin.readline()) + + +def SI(): +    return eval(input()) + + +n = II() +F = [LI() for _ in range(n)] +P = [LI() for _ in range(n)] -for i in range(1, 1 << 10): -    score = 0 -    for shop in range(N): -        both_open = 0 -        for period in range(10): -            if i >> period & F[shop][period] == 1: -                both_open += 1 -        score += P[shop][both_open] -    ans = max(ans, score) +for bit in range(1, 1024): +    profit = 0 +    for shop in range(n): +        cnt = 0 +        for shift in range(10): +            if not bit >> shift & 1: +                continue +            if F[shop][shift]: +                cnt += 1 +        profit += P[shop][cnt] +    ans = max(ans, profit)