n = int(input())
shop_i = []
for i in range(n):
    shop_i.append(list(map(int, input().split())))
gain_i = []
for i in range(n):
    gain_i.append(list(map(int, input().split())))

gain_max = -100000000
for i in range(2**10):
    if i ==0:
        pass
    else:        
        shop_sister = format(i, '010b')
        gain_now = []
        for shop in range(n):
            times = 0
            for n_cap in range(10):
                if shop_i[shop][n_cap] == 1 and shop_sister[n_cap] == '1':
                    times += 1
            gain_now.append(gain_i[shop][times]) 
        gain_now = sum(gain_now)
        if gain_now>gain_max:
            gain_max = gain_now

print(gain_max)
