N = int(raw_input())
F = []
for i in range(N):
    li = map(int,raw_input().split())
    F.append(li)
P = []
for i in range(N):
    li = map(int,raw_input().split())
    P.append(li)
bigest = None
for i in range(1024):
    kasa = []
    for x in range(N):
        kasa.append(0)
    i = i + 1 
    bi = str(bin(i)).split("b")[1]
    bi = (10-len(bi))*"0" + bi
    for i2 in range(10):
        if bi[i2]  == "1":
            for i3 in range(N):
                if F[i3][i2] == 1:
                    kasa[i3] += 1
    me = 0 
    for i2 in range(N):
        me += P[i2][kasa[i2]]
    if bigest < me or bigest == None:
        bigest = me
print bigest