#N,A,B=map(int, input().split())

 

#A=list(map(int, input().split()))

 

N=int(eval(input()))

 

F=[]

P=[]

 

for i in range(N):

    tmp=list(map(int, input().split()))

    F.append(tmp)

 

for i in range(N):

    tmp=list(map(int, input().split()))

    P.append(tmp)

 

max_sum=-1000000001

 

for i in range(1,1024):

    bin=[0]*10

    now=i

    for j in range(10):

        bin[j]=now%2

        now=now//2

    ans_sum=0

    for j in range(N):

        ans=0

        for h in range(10):

            if F[j][h]*bin[h]==1:

                ans+=1

        ans_sum+=P[j][ans]

    if max_sum<ans_sum:

        max_sum=ans_sum

 

print(max_sum)
#-*-coding:utf-8-*-



def main():

    n = int(eval(input()))

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

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



    max_profit = -1000000001

    

    for i in range(1, 2 ** 10):

        binary=[0]*10

        now=i

        for j in range(10):

            binary[j]=now%2

            now=now//2

        profit = 0

        for j in range(n):

            one_cnt = 0

            for h in range(10):

                if f_list[j][h]*binary[h]==1:

                    one_cnt += 1

            profit += p_list[j][one_cnt]

        if max_profit < profit:

            max_profit = profit

 

    print(max_profit)

    

if __name__ == '__main__':

    main()
# N,A,B=map(int, input().split())
# A=list(map(int, input().split()))
N = int(eval(input()))
F = []
P = []
for i in range(N):
    tmp = list(map(int, input().split()))
    F.append(tmp)
for i in range(N):
    tmp = list(map(int, input().split()))
    P.append(tmp)
max_sum = -1000000001
for i in range(1, 1024):
    bin = [0] * 10
    now = i
    for j in range(10):
        bin[j] = now % 2
        now = now // 2
    ans_sum = 0
    for j in range(N):
        ans = 0
        for h in range(10):
            if F[j][h] * bin[h] == 1:
                ans += 1
        ans_sum += P[j][ans]
    if max_sum < ans_sum:
        max_sum = ans_sum
print(max_sum)

# -*-coding:utf-8-*-
def main():
    n = int(eval(input()))
    f_list = [list(map(int, input().split())) for i in range(n)]
    p_list = [list(map(int, input().split())) for i in range(n)]
    max_profit = -1000000001
    for i in range(1, 2**10):
        binary = [0] * 10
        now = i
        for j in range(10):
            binary[j] = now % 2
            now = now // 2
        profit = 0
        for j in range(n):
            one_cnt = 0
            for h in range(10):
                if f_list[j][h] * binary[h] == 1:
                    one_cnt += 1
            profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
    print(max_profit)


if __name__ == "__main__":
    main()

-# N,A,B=map(int, input().split()) -# A=list(map(int, input().split())) -N = int(eval(input())) -F = [] -P = [] -for i in range(N): -    tmp = list(map(int, input().split())) -    F.append(tmp) -for i in range(N): -    tmp = list(map(int, input().split())) -    P.append(tmp) -max_sum = -1000000001 -for i in range(1, 1024): -    bin = [0] * 10 -    now = i -    for j in range(10): -        bin[j] = now % 2 -        now = now // 2 -    ans_sum = 0 -    for j in range(N): -        ans = 0 -        for h in range(10): -            if F[j][h] * bin[h] == 1: -                ans += 1 -        ans_sum += P[j][ans] -    if max_sum < ans_sum: -        max_sum = ans_sum -print(max_sum) +# -*-coding:utf-8-*- +def main(): +    n = int(eval(input())) +    f_list = [list(map(int, input().split())) for i in range(n)] +    p_list = [list(map(int, input().split())) for i in range(n)] +    max_profit = -1000000001 +    for i in range(1, 2**10): +        binary = [0] * 10 +        now = i +        for j in range(10): +            binary[j] = now % 2 +            now = now // 2 +        profit = 0 +        for j in range(n): +            one_cnt = 0 +            for h in range(10): +                if f_list[j][h] * binary[h] == 1: +                    one_cnt += 1 +            profit += p_list[j][one_cnt] +        if max_profit < profit: +            max_profit = profit +    print(max_profit) + + +if __name__ == "__main__": +    main()