#C
from collections import deque
import bisect
import math
import heapq
import itertools
import sys
input = sys.stdin.readline

inf = float("inf")
mod = 10**9 + 7
#mod = 998244353

#list(map(int,input().split()))

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)]

ite = [i for i in range(10)]

ans = []
for i in range(1023):
    if i == 0:
        continue
    b = bin(i)
    b = b.lstrip("0b")
    while len(b) < 10:
        b = "0"+b
    
    kari = 0
    for j in range(N):
        f = F[j]
        p = P[j]
        C = 0
        for k in range(10):
            if b[k] == "1" and f[k] == 1:
                C+=1
        kari += p[C]
    ans.append(kari)
    
print(max(ans))
        
    


