import numpy as np
n = int(input())
shop_i = []
for i in range(n):
    shop_i.append(np.array(list(map(int, input().split()))).astype(np.bool))
gain_i = []
for i in range(n):
    gain_i.append(np.array(list(map(int, input().split()))))

gain_max = -100000000
for i in range(2**10):
    if i ==0:
        pass
    else:        
        shop_sister = format(i, '010b')
        me = np.array([shop_sister[keta] for keta in range(10)]).astype(np.bool)
        gain_now = []
        for shop in range(n):
            togather = sum(me&shop_i[shop])
            gain_now.append(gain_i[shop][togather]) 
        gain_now = sum(gain_now)
        if gain_now>gain_max:
            gain_max = gain_now

print(gain_max)
