local n=io.read("n")
local f={}
for i=1,n do
    f[i]={}
    for j=0,9 do
        f[i][j]=io.read("n")
    end
end
local p={}
for i=1,n do
    p[i]={}
    for j=0,10 do
        p[i][j]=io.read("n")
    end
end

local max=-math.maxinteger
for bit=1,(1<<10)-1 do
    local gain=0
    for i=1,n do
        local open=0
        for j=0,9 do
            if (bit>>j&1)>0 and f[i][j]~=0 then
                open=open+1
            end
        end
        gain=gain+p[i][open]
    end
    if max<gain then
        max=gain
    end
end
print(max)