N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
P_list = []


for i in range(1, 2 ** 10 - 1):
    a = list(bin(i))[2::]
    while len(a) < 10:
        a = ["0"] + a
    P_list.append(a)
finalans = -100000000000
for i in P_list:
    ans = 0
    cnt = [0 for i in range(N)]
    for j in range(10):
        if i[j] == "1":
            for k in range(N):
                if F[k][j] == 1:
                    cnt[k] += 1
    for j in range(N):
        ans += P[j][cnt[j]]
    #print(ans)
    finalans = max(finalans, ans)

print(finalans)
