N = int(input())
F = []
for i in range(N):
    F.append(list(map(int,input().split())))
P = []
for i in range(N):
    P.append(list(map(int,input().split())))
MAX = -100000000
for j in range(1023):
    if j == 0:
        pass
    else:
        Fcount = [0 for a in range(N)]
        b = bin(j)
        blist = list(b)
        del blist[:2]
        L = len(blist)
        for k in range(10-L):
            blist.insert(0,"0")
        m = 0
        for m in range(10):
            if blist[m] == "1":
                o = 0
                for o in range(N):
                    if F[o][m] == 1:
                        Fcount[o]+=1
                    else:
                        pass
            else:
                pass
        kari = 0
        p = 0
        for p in range(N):
            kari+=P[p][Fcount[p]]
        if MAX <= kari and ("1" in blist):
            MAX = kari

print(MAX)