n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
ans = []
for i in range(1,2**10):
    a = [0]*n
    for j in range(10):
        if i >> j & 1:
            for k in range(n):
                a[k] += f[k][j]
    ans.append(sum([p[i][a[i]] for i in range(n)]))
print(max(ans))