#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::BinaryHeap;
use std::collections::HashSet;
use std::cmp::Ordering;


fn main() {
    input! {
        x: usize,
        y: usize,
        z: usize,
        k: usize,
        mut a: [u64; x],
        mut b: [u64; y],
        mut c: [u64; z],
    }

   #[derive(Eq, Hash, Clone, Copy)]
    struct Cake {
        deli: u64,
        comb: (usize, usize, usize),
    }

    impl PartialEq for Cake {
        fn eq(&self, other: &Self) -> bool {
            self.deli == other.deli
            && self.comb == other.comb
        }
    }

    impl Ord for Cake {
        fn cmp(&self, other: &Self) -> Ordering {
            self.deli.cmp(&other.deli)
        }
    }

    impl PartialOrd for Cake {
        fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
            Some(self.cmp(other))
        }
    }

    a.sort_by(|a, b| b.cmp(a));
    b.sort_by(|a, b| b.cmp(a));
    c.sort_by(|a, b| b.cmp(a));

    let mut que = BinaryHeap::new();
    let mut set = HashSet::new();

    que.push(Cake {deli: a[0]+b[0]+c[0], comb: (0,0,0)});
    set.insert(Cake {deli: a[0]+b[0]+c[0], comb: (0,0,0)});

    for _ in 0..k {
        let ans = que.pop().unwrap();
        println!("{}", ans.deli);

        if ans.comb.0 + 1 < x { 
        let t1 = Cake {deli: a[ans.comb.0+1] + b[ans.comb.1] + c[ans.comb.2], comb: (ans.comb.0+1, ans.comb.1, ans.comb.2)};
        if !set.contains(&t1) {
            que.push(t1);
            set.insert(t1);
        }
        }

        if ans.comb.1 + 1 < y { 
        let t2 = Cake {deli: a[ans.comb.0] + b[ans.comb.1+1] + c[ans.comb.2], comb: (ans.comb.0, ans.comb.1+1, ans.comb.2)};
        if !set.contains(&t2) {
            que.push(t2);
            set.insert(t2);
        }
        }


        if ans.comb.2 + 1 < z { 
        let t3 = Cake {deli: a[ans.comb.0] + b[ans.comb.1] + c[ans.comb.2+1], comb: (ans.comb.0, ans.comb.1, ans.comb.2+1)};
        if !set.contains(&t3) {
            que.push(t3);
            set.insert(t3);
        }
        }
    }

    
}





Measured memory_bytes: 4352