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

for i in range(N):
    P.append(list(map(int,input().split())))
    
    
def calc_profit(open_list):
    count = [0 for i in range(N)]
    for i in range(10):
        if open_list[i]:
            for j in range(N):
                if F[j][i]==1:
                    count[j]+=1
    profit=0
    for i in range(N):
        profit+=P[i][count[i]]
    return profit


def get_max(l):
    if len(l)==10:
        return calc_profit(l)
    else:
        return max(get_max(l+[True]),get_max(l+[False]))
print(get_max([]))