n = int(input())
f = [list(input().split()) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

result = []
for i in range(1, 2**10):
    b = format(i, "010b")
    r = 0
    for j in range(n):
        c = [1 for I in range(10) if b[I]==f[j][I]=="1"]
        r += p[j][len(c)]
    result.append(r)
print(max(result))