"use strict";
// User defined class
// to store element and its priority
class QElement {
    constructor(element, priority) {
        this.element = element;
        this.priority = priority;
    }
}


// PriorityQueue class
class PriorityQueue {

    // An array is used to implement priority
    constructor() {
        this.items = [];
    }

    // enqueue function to add element
    // to the queue as per priority
    enqueue(element, priority) {

        // creating object from queue element
        var qElement = new QElement(element, priority);
        var contain = false;

        // iterating through the entire
        // item array to add element at the
        // correct location of the Queue
        for (var n = 0; n < this.items.length; n++) {
            if (this.items[n].priority < qElement.priority) {
                // Once the correct location is found it is
                // enqueued
                this.items.splice(n, 0, qElement);
                contain = true;
                break;
            }
        }

        // if the element have the highest priority
        // it is added at the end of the queue
        if (!contain) {
            this.items.push(qElement);
        }
    }

    // dequeue method to remove
    // element from the queue
    dequeue() {
        // return the dequeued element
        // and remove it.
        // if the queue is empty
        // returns Underflow
        if (this.isEmpty()) return "Underflow";
        return this.items.shift();
    }

    // front function
    front() {
        // returns the highest priority element
        // in the Priority queue without removing it.
        if (this.isEmpty()) return "No elements in Queue";
        return this.items[0];
    }

    // rear function
    rear() {
        // returns the lowest priorty
        // element of the queue
        if (this.isEmpty()) return "No elements in Queue";
        return this.items[this.items.length - 1];
    }

    // isEmpty function
    isEmpty() {
        // return true if the queue is empty.
        return this.items.length == 0;
    }

    // printQueue function
    // prints all the element of the queue
    printPQueue() {
        var str = "";
        for (var n = 0; n < this.items.length; n++)
            str += this.items[n].element + " ";
        return str;
    }
}

function Main(input) {
    let lines = input.split("\n");
    let xyzk = lines.shift().split(/\s/).map((v) => v - 0);
    let X = xyzk[0], Y = xyzk[1], Z = xyzk[2], K = xyzk[3];
    let A = lines.shift().split(/\s/).map((v) => v - 0).sort((a, b) => b - a);
    let B = lines.shift().split(/\s/).map((v) => v - 0).sort((a, b) => b - a);
    let C = lines.shift().split(/\s/).map((v) => v - 0).sort((a, b) => b - a);
    A.push(-1e12);
    B.push(-1e12);
    C.push(-1e12);
    const d4 = (n) => ('0000' + n).slice(-4);
    const hashed = (a, b, c) => d4(a) + d4(b) + d4(c);

    let pq = new PriorityQueue();
    let s = new Set();
    pq.enqueue([0, 0, 0], A[0] + B[0] + C[0]);
    s.add(hashed(0, 0, 0));
    let ans = [];
    while (ans.length < K) {
        let v = pq.dequeue();
        ans.push(v.priority);
        for (let n = 0; n < 3; n++) {
            let a = v.element[0]; if (n == 0) a++;
            let b = v.element[1]; if (n == 1) b++;
            let c = v.element[2]; if (n == 2) c++;
            let hash = hashed(a, b, c);
            if (!s.has(hash)) {
                s.add(hash);
                pq.enqueue([a, b, c], A[a] + B[b] + C[c]);
            }
        }
    }
    for (let n = 0; n < K; n++) {
        console.log(ans[n]);
    }
}
if (typeof window === 'undefined') Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15664