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

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

    max_profit = -10000001

    for i in range(1, 1024):
        binary = [0] * 10
        now = i 
        for j in range(10):
            binary[j] = now % 2
            now = now // 2
        profit = 0
        for j in range(n):
            one_cnt = 0
            for h in range(10):
                if f_list[j][h] * binary[h] == 1:
                    one_cnt += 1
            profit += p_list[j][one_cnt]
        if max_profit < profit:
            max_profit = profit
    print(max_profit)
    
    
if __name__ == '__main__':
    main()