do  --  Library
    table.map = function(t, f)
        local ret = {}
        for i = 1, #t do
            table.insert(ret, f(t[i]))
        end
        return ret
    end
    
    table.each = function(t, f)
        for i = 1, #t do
            f(t[i])
        end
    end
    
    table.sum = function(t)
        local sum = 0
        for i = 1, #t do
            sum = sum + t[i]
        end
        return sum
    end
    
    table.slice = function(t, b, e)
        local ret = {}
        for i = b, e do
            table.insert(ret, t[i])
        end
        return ret
    end
    
    string.split = function(str, sep)
        local ret = {}
        for i in string.gmatch(str, "[^"..sep.."]+") do
            table.insert(ret, i)
        end
        return ret
    end
end

calculate = nil
do
    local memo = {}
    local stages_to_str = function(stages)
        return table.concat(table.map(stages, tostring), ",")
    end
    
    function calculate(top_num, under_stages)
        local str_under_stages = stages_to_str(under_stages)
        if not memo[top_num] then
            memo[top_num] = {}
        elseif memo[top_num][str_under_stages] then
            return memo[top_num][str_under_stages]
        end
        
        if #under_stages == 0 then
            return 1
        end
        
        memo[top_num][str_under_stages] = table.sum(table.map(under_stages[1], function(size)
            if size <= top_num then
                return 0
            end
            
            return calculate(size, table.slice(under_stages, 2, #under_stages))
        end))
        return memo[top_num][str_under_stages]
    end
end

function main()
    local n = tonumber(io.read())
    local stages = {}
    for i = 1, 3 do
        table.insert(stages, table.map(string.split(io.read(), " "), tonumber))
    end
    
    table.each(stages, function(t)
        table.sort(t, function(a, b) return b < a end)
    end)
    
    print(calculate(0, stages))
end

main()