Scanf.scanf "%d %d %d %d" (fun x y z k ->
    let a = Array.init x (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
    let b = Array.init y (fun _ -> Scanf.scanf " %d" (fun y -> y)) in
    let c = Array.init z (fun _ -> Scanf.scanf " %d" (fun z -> z)) in
    Array.sort (fun a b -> compare b a) a;
    Array.sort (fun a b -> compare b a) b;
    Array.sort (fun a b -> compare b a) c;
    let buf1 = Array.make (x * y) 0 in
    for i = 0 to x - 1 do
        for j = 0 to y - 1 do
            buf1.(i * y + j) <- a.(i) + b.(j)
        done
    done;
    Array.sort (fun a b -> compare b a) buf1;
    let xy = min 3000 (x * y) in
    let buf2 = Array.make (xy * z) 0 in
    for i = 0 to xy - 1 do
        for j = 0 to z - 1 do
            buf2.(i * z + j) <- buf1.(i) + c.(j)
        done
    done;
    Array.sort (fun a b -> compare b a) buf2;
    for i = 0 to k - 1 do
        Printf.printf "%d\n" buf2.(i)
    done
)