n = int(input())
opened = [int('0b' + input().replace(' ', '')[::-1], 2) for i in range(n)]
prise = [list(map(int, input().split())) for i in range(n)]

ans = -float('INF')
for i in range(1,1<<10-1):
    cnt = [0 for i in range(n)]
    for j in range(10):
        if 1<<j & i:
            continue
        for k in range(n):
            if 1<<j & opened[k]:
                cnt[k] += 1
    tmp = sum([prise[k][cnt[k]] for k in range(n)])
    if tmp > ans:
        ans = tmp
print(ans)
# print(bin(2^10-1))
# [print(bin(i)) for i in opened]
