N = int(input())
F = []
P = []
ans = -10**8
def cal_same_num(F,temp):
    num_same = 0
    for i in range(10):
        if temp[i] == "1" and F[i] == 1:
            num_same += 1
    return num_same

for i in range(N):
    F.append(list(map(int,input().split(" "))))
for i in range(N):
    P.append(list(map(int,input().split(" "))))

for i in range(1,2**10):
    sum_point = 0
    temp = str(format(i,"b")).zfill(10)
    for j in range(N):
        num_same = cal_same_num(F[j],temp)
        point = P[j][num_same]
        sum_point += point
    ans = max(ans,sum_point)
print(ans)