n = int(input())
# frr = [
#     [1, 1, 1, 1, 1, 1, 0, 0, 1, 1],
#     [0, 1, 0, 1, 1, 1, 1, 0, 1, 0],
#     [1, 0, 1, 1, 0, 1, 0, 1, 0, 1]
# ]
#
# prr = [
#     [-8, 6, -2, -8, -8, 4, 8, 7, -6, 2, 2],
#     [-9, 2, 0, 1, 7, -5, 0, -2, -6, 5, 5],
#     [6, -6, 7, -9, 6, -5, 8, 0, -9, -7, -7],
# ]

frr = []

for i in range(n):
    frr.append([int(s) for s in input().split(" ")])

prr = []

for i in range(n):
    prr.append([int(s) for s in input().split(" ")])


res = []
for i in range(1,2 ** 11):
    count = [0 for s in range(n)]

    mask = []
    for j in range(10):
        m =  i >> j & 1
        if m == 1:
            for k in range(n):
                if frr[k][j] == 1:
                    count[k] = count[k] + 1

    mm = []
    for index,c in enumerate(count):
        mm.append(prr[index][c])

    res.append(sum(mm))

print(max(res))

