quickSortList :: [a] -> [a]
quickSortList [] = []
quickSortList (x:xs) = quickSortList lt ++ [x] ++ quickSortList gt
  where
    lt = filter (<x) xs
    gt = filter (>=x) xs
    
main = do
    k <- last . map read . words <$> getLine
    a_s <- map read . words <$> getLine
    b_s <- map read . words <$> getLine
    c_s <- map read . words <$> getLine
    x_s = [a * b * c | a <- a_s , b <- b_s , c <- c_s]
    take k quickSortList x_s