import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

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

def main():
    N=int(input())
    F=np.array([list(map(int,input().split())) for _ in range(N)])
    P=np.array([list(map(int,input().split())) for _ in range(N)])
    ans=-10**9
    for i in range(1,1<<10-1):
        tmp=0
        for j in range(N):
            cnt=0
            for k in range(10):
                if (i>>k)&(F[j,k])==1:
                    cnt+=1
            tmp+=P[j,cnt]
        ans=max(ans,tmp)
    print(ans)






if __name__ == '__main__':
    main()