# -*- coding: utf-8 -*-



import itertools



N = int(eval(input()))

F = []

for i in range(N):

    F.append(list(map(int, input().split())))

P = []

for i in range(N):

    P.append(list(map(int, input().split())))



# 重複順列で自分の店の全パターンを出す

me_list = list(itertools.product([0, 1], repeat=10))



# 初期値は利益の最小値

me_p = -float("inf")

# 自分の店の全パターンループ

for i in range(len(me_list)):



    # 一度も営業しないパターンを除く

    if i == 0:

        continue



    tmp_p = 0

    # 他店の数でループ

    for j in range(N):



        cnt = 0

        # 月～金のAMPMループ

        for k in range(10):



            # 他店との営業重複カウント

            if me_list[i][k] == 1 and F[j][k] == 1:

                cnt += 1

        

        # 各店舗との重複数に応じた利益を合算していく

        tmp_p += P[j][cnt]



    # 合算した利益を現状の最高値と比較して置き換えていく

    me_p = max(me_p, tmp_p)   



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



import sys



def input(): return sys.stdin.readline().strip()

def list2d(a, b, c): return [[c] * b for i in range(a)]

def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1): return int(-(-x // y))

def INT(): return int(eval(input()))

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

def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes(): print('Yes')

def No(): print('No')

def YES(): print('YES')

def NO(): print('NO')

sys.setrecursionlimit(10 ** 9)

INF = 10 ** 18

MOD = 10 ** 9 + 7



N = INT()

A = list2d(N, 10, 0)

for i in range(N):

    A[i] = LIST()

B = list2d(N, 11, 0)

for i in range(N):

    B[i] = LIST()



ans = -INF

# 全時間帯でビット全探索(全0以外)

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

    sm = 0

    for i in range(N):

        cnt = 0

        for j in range(10):

            if S & 1<<j and A[i][j]:

                cnt += 1

        sm += B[i][cnt]

    ans = max(ans, sm)

print(ans)

# -*- coding: utf-8 -*-
import itertools

N = int(eval(input()))
F = []
for i in range(N):
    F.append(list(map(int, input().split())))
P = []
for i in range(N):
    P.append(list(map(int, input().split())))
# 重複順列で自分の店の全パターンを出す
me_list = list(itertools.product([0, 1], repeat=10))
# 初期値は利益の最小値
me_p = -float("inf")
# 自分の店の全パターンループ
for i in range(len(me_list)):
    # 一度も営業しないパターンを除く
    if i == 0:
        continue
    tmp_p = 0
    # 他店の数でループ
    for j in range(N):
        cnt = 0
        # 月～金のAMPMループ
        for k in range(10):
            # 他店との営業重複カウント
            if me_list[i][k] == 1 and F[j][k] == 1:
                cnt += 1
        # 各店舗との重複数に応じた利益を合算していく
        tmp_p += P[j][cnt]
    # 合算した利益を現状の最高値と比較して置き換えていく
    me_p = max(me_p, tmp_p)
print(me_p)

# -*- coding: utf-8 -*-
import sys


def input():
    return sys.stdin.readline().strip()


def list2d(a, b, c):
    return [[c] * b for i in range(a)]


def list3d(a, b, c, d):
    return [[[d] * c for j in range(b)] for i in range(a)]


def list4d(a, b, c, d, e):
    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]


def ceil(x, y=1):
    return int(-(-x // y))


def INT():
    return int(eval(input()))


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


def LIST(N=None):
    return list(MAP()) if N is None else [INT() for i in range(N)]


def Yes():
    print("Yes")


def No():
    print("No")


def YES():
    print("YES")


def NO():
    print("NO")


sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
N = INT()
A = list2d(N, 10, 0)
for i in range(N):
    A[i] = LIST()
B = list2d(N, 11, 0)
for i in range(N):
    B[i] = LIST()
ans = -INF
# 全時間帯でビット全探索(全0以外)
for S in range(1, 1 << 10):
    sm = 0
    for i in range(N):
        cnt = 0
        for j in range(10):
            if S & 1 << j and A[i][j]:
                cnt += 1
        sm += B[i][cnt]
    ans = max(ans, sm)
print(ans)

-import itertools +import sys -N = int(eval(input())) -F = [] + +def input(): +    return sys.stdin.readline().strip() + + +def list2d(a, b, c): +    return [[c] * b for i in range(a)] + + +def list3d(a, b, c, d): +    return [[[d] * c for j in range(b)] for i in range(a)] + + +def list4d(a, b, c, d, e): +    return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] + + +def ceil(x, y=1): +    return int(-(-x // y)) + + +def INT(): +    return int(eval(input())) + + +def MAP(): +    return list(map(int, input().split())) + + +def LIST(N=None): +    return list(MAP()) if N is None else [INT() for i in range(N)] + + +def Yes(): +    print("Yes") + + +def No(): +    print("No") + + +def YES(): +    print("YES") + + +def NO(): +    print("NO") + + +sys.setrecursionlimit(10**9) +INF = 10**18 +MOD = 10**9 + 7 +N = INT() +A = list2d(N, 10, 0) -    F.append(list(map(int, input().split()))) -P = [] +    A[i] = LIST() +B = list2d(N, 11, 0) -    P.append(list(map(int, input().split()))) -# 重複順列で自分の店の全パターンを出す -me_list = list(itertools.product([0, 1], repeat=10)) -# 初期値は利益の最小値 -me_p = -float("inf") -# 自分の店の全パターンループ -for i in range(len(me_list)): -    # 一度も営業しないパターンを除く -    if i == 0: -        continue -    tmp_p = 0 -    # 他店の数でループ -    for j in range(N): +    B[i] = LIST() +ans = -INF +# 全時間帯でビット全探索(全0以外) +for S in range(1, 1 << 10): +    sm = 0 +    for i in range(N): -        # 月～金のAMPMループ -        for k in range(10): -            # 他店との営業重複カウント -            if me_list[i][k] == 1 and F[j][k] == 1: +        for j in range(10): +            if S & 1 << j and A[i][j]: -        # 各店舗との重複数に応じた利益を合算していく -        tmp_p += P[j][cnt] -    # 合算した利益を現状の最高値と比較して置き換えていく -    me_p = max(me_p, tmp_p) -print(me_p) +        sm += B[i][cnt] +    ans = max(ans, sm) +print(ans)