import sequtils,strutils,math
var
    N = stdin.readline.parseInt
    F : array[101, seq[int]]
    P : array[101, seq[int]]
    m : int
    ans : int = -100_000_000
    
    
for i in 0..<N:
    F[i] = stdin.readline.split.map(parseInt)
for i in 0..<N:
    P[i] = stdin.readline.split.map(parseInt)


for i in 1..1023:
    m = 0
    var
        cnt : array[101, int]
    for j in 0..9:
        if (i and (1 shl j)) > 0:
            for n in 0..<N:
                if F[n][j] == 1:
                    cnt[n] += 1
    for n in 0..<N:
        m += P[n][cnt[n]]
    ans = max(m, ans)
echo ans