{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad
import Data.Int (Int64)
import Data.List
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import Data.Ord
import Data.Coerce

sortDown :: forall a. (Ord a) => [a] -> [a]
sortDown = coerce . (sort :: [Down a] -> [Down a]) . coerce

data Pair = Pair {-# UNPACK #-} !Int64 {-# UNPACK #-} !Int deriving (Eq,Ord,Show)

mergeTwo :: [Pair] -> [Pair] -> [Pair]
mergeTwo xs@(x@(Pair xv xn):xss) ys@(y@(Pair yv yn):yss) = case compare xv yv of
  LT -> y : mergeTwo xs yss
  EQ -> let !zn = xn + yn in (Pair xv zn) : mergeTwo xss yss
  GT -> x : mergeTwo xss ys
mergeTwo [] ys = ys
mergeTwo xs [] = xs

-- replicate' n x ys = replicate n x ++ ys
replicate' :: Int -> a -> [a] -> [a]
replicate' 0 x ys = ys
replicate' n x ys = x : replicate' (n - 1) x ys

undup :: [Pair] -> [Int64]
undup ((Pair xv xn):xs) = replicate' xn xv $ undup xs
undup [] = []

mergeLists :: [[Pair]] -> [Int64]
mergeLists [] = []
mergeLists (xs:sss) = doMerge' xs sss
  where
    doMerge' xs (ys:sss) = doMerge xs ys sss
    doMerge' xs [] = undup xs
    doMerge xs (y@(Pair yv yn):yss) sss = innerLoop xs yv yn yss sss
      where innerLoop xs@(x@(Pair xv xn):xss) !yv !yn yss sss = case compare xv yv of
              LT -> replicate' yn yv $ doMerge' (mergeTwo xs yss) sss
              EQ -> replicate' (xn + yn) xv $ doMerge' (mergeTwo xss yss) sss
              GT -> replicate' xn xv $ innerLoop xss yv yn yss sss
            innerLoop [] !yv !yn yss sss = replicate' yn yv $ doMerge' yss sss
    doMerge [] ys [] = undup ys
    doMerge [] ys (zs:sss) = doMerge ys zs sss
    doMerge xs [] (ys:sss) = doMerge xs ys sss
    doMerge xs [] [] = undup xs

mergeDup :: [Int64] -> [(Int64, Int)]
mergeDup (x:xs) = loop 1 x xs
  where loop !i !x ys@(y:yss) | x == y = loop (i+1) x yss
                              | otherwise = (x,i) : mergeDup ys
        loop !i !x [] = [(x,i)]
mergeDup [] = []

mergeDup2 :: [Pair] -> [Pair]
mergeDup2 ((Pair x n):xs) = loop n x xs
  where loop !i !x ys@((Pair y m):yss) | x == y = loop (i+m) x yss
                                       | otherwise = (Pair x i) : mergeDup2 ys
        loop !i !x [] = [(Pair x i)]
mergeDup2 [] = []

main = do
  [x,y,z,k] :: [Int] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- x,y,z <= 1000
  -- k <= min 3000 (x*y*z)
  as :: U.Vector (Int64, Int) <- U.fromListN x . mergeDup . sortDown . map (read . BS.unpack) . BS.words <$> BS.getLine
  bs :: U.Vector (Int64, Int) <- U.fromListN y . mergeDup . sortDown . map (read . BS.unpack) . BS.words <$> BS.getLine
  cs :: U.Vector (Int64, Int) <- U.fromListN z . mergeDup . sortDown . map (read . BS.unpack) . BS.words <$> BS.getLine
  -- ai,bi,ci <= 10^10, length as == x, length bs == y, length cs == z
  let !x' = U.length as
      !y' = U.length bs
      !z' = U.length cs
  let xs = [ mergeDup2 $ sortDown
             [ (Pair s nn)
             | i <- [0 .. min t (x' - 1)]
             , j <- [max 0 (t - z' - i + 1) .. min (t-i) (y'-1)]
             , let !k = t - i - j
                   (a,an) = as U.! i
                   (b,bn) = bs U.! j
                   (c,cn) = cs U.! k
                   !s = a + b + c
                   !nn = an * bn * cn
             -- i + j + k = t
             ]
           | t <- [0 .. x' + y' + z' - 3]
           ]
  let result = take k $ mergeLists xs
  mapM_ print result
