
N = int(input())

F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]

#%%
INF = 1<<60
ans = -INF
for st in range(1,1<<10):
    t = st
    state = [0]*10
    for i in range(10):
        state[i] = t%2
        t >>= 1
    
    cur = 0
    for k in range(N):
        tmp = 0
        for i in range(10):
            if F[k][i] == 1 and state[i] == 1:
                tmp += 1
        cur += P[k][tmp]
        ans = max(ans,cur)

print(cur)