import itertools
n = int(input())
p,f = [],[]

for i in range(n):
    f.append(list(map(int,input().split())))
for i in range(n):
    p.append(list(map(int,input().split())))

a = [0,1]
ans = 0
for v in itertools.product(a,repeat = 10):
    if sum(v) != 0:
        s = []
        for a in range(n):
            k = 0
            for b in range(10):
                if f[a][b] == v[b] and v[b] == 1:
                    k += 1
            s.append(k)

        x = 0
        for a in range(n):
            x += p[a][s[a]]
        if x > ans:
            #print(v,s,x)
            ans = x

print(ans)