# -*- coding: utf-8 -*-

N = int(input().strip())
F_list = [list(map(int, input().rstrip().split())) for i in range(N)]
P_list = [list(map(int, input().rstrip().split())) for i in range(N)]
#-----

bin_str = format(2**10 - 1 , 'b').zfill(10)

total_profit_list=[]
for x in range(1,2**10 - 1):
    bin_str = format(x, 'b').zfill(10)

    profit=0
    for i in range(N):
        c=0
        for j in range(10):
            if int(bin_str[j]) == F_list[i][j] == 1:
                c += 1
        profit += P_list[i][c]
    
    total_profit_list.append(profit)

print(max(total_profit_list))
