n = int(input())
f = []
for i in range(n):
    f.append(list(int(i) for i in input().split()))

p = []
for i in range(n):
    p.append(list(int(i) for i in input().split()))

res = -10**7
for b in range(1,2**10):
    bit = bin(b)[2:]
    bit = '0'*(10-len(bit))+bit
    tmp = 0
    for i in range(n):
        count = 0
        for j in range(10):
            if int(bit[j])==f[i][j]==1:
                count += 1
        tmp += p[i][count]
    res = max(res,tmp)
print(res)
    