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

ans = -123456789
for mask in range(1,2**10):
    tmp = 0
    updated = False
    for i in range(n):
        cnt = 0
        for x in range(10):
            if (mask>>x) % 2 == 1 and f[i][x] == 1: cnt += 1
        tmp += p[i][cnt]
        if cnt > 0 : updated = True
    if updated: ans = max(ans, tmp)

print(ans)
