#[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")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

use std::cmp::Ordering;

#[derive(Clone, Eq, PartialEq)]
struct State {
    x: usize,
    y: usize,
    z: usize,
    cost: usize,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        self.cost.cmp(&other.cost)
    }
}

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

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

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

    let mut heap = BinaryHeap::new();
    let s = State {
        x: a.len() - 1,
        y: b.len() - 1,
        z: c.len() - 1,
        cost: a[a.len() - 1] + b[b.len() - 1] + c[c.len() - 1],
    };
    let mut hash = HashMap::new();
    hash.insert((s.x, s.y, s.z), s.cost);
    heap.push(s);
    let mut i = 0;
    while !heap.is_empty() && i < k {
        let s = heap.pop().unwrap();
        if hash.get(&(s.x, s.y, s.z)).unwrap() < &s.cost {
            continue;
        }
        println!("{}", &s.cost);
        i += 1;
        for x in 0..2 {
            for y in 0..2 {
                for z in 0..2 {
                    if x > s.x || y > s.y || z > s.z {
                        continue;
                    }
                    let nx = s.x - x;
                    let ny = s.y - y;
                    let nz = s.z - z;
                    let nc = a[nx] + b[ny] + c[nz];
                    let ns = State {
                        x: nx,
                        y: ny,
                        z: nz,
                        cost: nc,
                    };
                    if hash.get(&(nx, ny, nz)).is_none() || *hash.get(&(nx, ny, nz)).unwrap() < nc {
                        hash.insert((nx, ny, nz), nc);
                        heap.push(ns);
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 6396