n = input()
f = [raw_input().split() for _ in xrange(n)]
p = [map(int, raw_input().split()) for _ in xrange(n)]
a = -9999999999L
for _ in xrange(1, 1024):
    cnt, b = 0, '0' * (12 - len(bin(_))) + bin(_)[2:]
    for i, n in enumerate(f):
        ci = 0
        for x in xrange(10):
            if b[x] == n[x] and b[x] == '1':
                ci += 1
        cnt += (p[i][ci])
    a = max(cnt, a)
print a