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

def main():
    n = int(input())
    f_list = []
    for i in range(n):
        f_list.append(list(map(int, input().split())))
    p_list = []
    for i in range(n):
        p_list.append(list(map(int, input().split())))

    max_profit = -10000000

    for i in range(1, 2 ** 10):
        for j in range(len(f_list)):
            one_cnt = 0
            binary = '{:010b}'.format(i)
            binary = [int(k) for k in list(binary)]
            for l in range(10):
                if binary[l] == f_list[j][l] and binary[l] == 1:
                    one_cnt += 1
            if j == 0:
                profit = p_list[j][one_cnt]
            else:
                profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
    print(max_profit)
            
if __name__ == '__main__':
    main()