CodeEff/ECCO huggingface dataset:
# Original solution

import itertools

def main():
    X, Y, Z, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    p = itertools.product(A, B)
    data = [i + j for i, j in p]
    data.sort(reverse=True)
    data = data[:min(len(data), K)]

    p = itertools.product(data, C)
    data = [i + j for i, j in p]
    data.sort(reverse=True)
    # data = data[:K]

    for i in range(K):
        print((data[i]))

if __name__ == '__main__':
    main()


# Optimized solution


def main():
    X, Y, Z, K = list(map(int, input().split()))

    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)


    data = []
    for i in range(X):
        for j in range(Y):
            if i * j > K:
                break
            for k in range(Z):
                if i * j * k > K:
                    break
                data.append(A[i] + B[j] + C[k])

    data.sort(reverse=True)

    for i in range(K):
        print((data[i]))

if __name__ == '__main__':
    main()
# Original solution
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
x, y, z, kk = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


ll = [0] * 10000000
count = 0
for i in range(len(a)):
    for j in range(len(b)):
        if i * j > kk:

            break
        for k in range(len(c)):
            if i * j * k > kk:
                break
            ll[count] = a[i] + b[j] + c[k]
            count += 1
ll.sort(reverse=True)

for i in range(kk):
    print((ll[i]))

# 空白区切り文字列
# t, d = input().split()


# Optimized solution
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
x, y, z, kk = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


ll = []
count = 0
for i in range(len(a)):
    for j in range(len(b)):
        if i * j > kk:

            break
        for k in range(len(c)):
            if i * j * k > kk:
                break
            ll.append(a[i] + b[j] + c[k])
ll.sort(reverse=True)

for i in range(kk):
    print((ll[i]))

# 空白区切り文字列
# t, d = input().split()
# Original solution
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
x, y, z, k = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ll = [0] * 1000001
count = 0
for i in a:
    for j in b:
        ll[count] = i + j
        count += 1
ll.sort(reverse=True)

ll = ll[0:3000]
c.sort(reverse=True)

lll = [0] * 3000001
count = 0
for i in ll:
    for j in c:
        lll[count] = i + j
        count += 1
lll.sort(reverse=True)

for i in range(k):
    print((lll[i]))

# 空白区切り文字列
# t, d = input().split()


# Optimized solution
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
x, y, z, kk = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


ll = []
count = 0
for i in range(len(a)):
    for j in range(len(b)):
        if i * j > kk:

            break
        for k in range(len(c)):
            if i * j * k > kk:
                break
            ll.append(a[i] + b[j] + c[k])
ll.sort(reverse=True)

for i in range(kk):
    print((ll[i]))

# 空白区切り文字列
# t, d = input().split()
# Original solution
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

X,Y,Z,K=MAP()
A=LIST()
B=LIST()
C=LIST()

AB=[]
for i in range(X):
    for j in range(Y):
        AB.append(A[i]+B[j])
AB.sort(reverse=True)
AB=AB[:3000]

ABC=[]
for i in range(len(AB)):
    for j in range(Z):
        ABC.append(AB[i]+C[j])
ABC.sort(reverse=True)

for i in range(K):
    print((ABC[i]))


# Optimized solution
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

X,Y,Z,K=MAP()
A=sorted(LIST(), reverse=True)
B=sorted(LIST(), reverse=True)
C=sorted(LIST(), reverse=True)

ABC=[]
for i in range(X):
    for j in range(Y):
        if (i+1)*(j+1)>K:
            break
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            ABC.append(A[i]+B[j]+C[k])
ABC.sort(reverse=True)
for i in range(K):
    print((ABC[i]))
# Original solution
x, y, z, k = list(map(int, input().split()))
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
c = tuple(map(int, input().split()))

ab = [i + j for i in a for j in b]
ab.sort(reverse=True)
abc = [i + j for i in ab[:k] for j in c]

abc.sort(reverse=True)
print(("\n".join(map(str, abc[:k]))))


# Optimized solution
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans = []
for i in range(x):
    for j in range(y):
        for m in range(z):
            if (i+1) * (j+1) * (m+1) > k:
                break
            ans.append(a[i] + b[j] + c[m])

ans.sort(reverse=True)
for i in ans[:k]:
    print(i)
# Original solution
from heapq import heappop, heappush

X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

h = []
heappush(h, (-A[0]-B[0]-C[0], 0, 0, 0))
used = set()
result = []

for _ in range(K):
    sum, i, j, k = heappop(h)
    result.append(-sum)
    if i < X-1 and (i+1, j, k) not in used:
        heappush(h, (-A[i+1]-B[j]-C[k], i+1, j, k))
        used.add((i+1, j, k))
    if j < Y-1 and (i, j+1, k) not in used:
        heappush(h, (-A[i]-B[j+1]-C[k], i, j+1, k))
        used.add((i, j+1, k))
    if k < Z-1 and (i, j, k+1) not in used:
        heappush(h, (-A[i]-B[j]-C[k+1], i, j, k+1))
        used.add((i, j, k+1))

for v in result:
    print(v)


# Optimized solution
from heapq import heappop, heappush

X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

used = set()
h = []
heappush(h, (-A[0]-B[0]-C[0], 0, 0, 0))
result = []
used.add((0, 0, 0))

for _ in range(K):
    sum, i, j, k = heappop(h)
    result.append(-sum)
    if i < X-1 and (i+1, j, k) not in used:
        heappush(h, (-A[i+1]-B[j]-C[k], i+1, j, k))
        used.add((i+1, j, k))
    if j < Y-1 and (i, j+1, k) not in used:
        heappush(h, (-A[i]-B[j+1]-C[k], i, j+1, k))
        used.add((i, j+1, k))
    if k < Z-1 and (i, j, k+1) not in used:
        heappush(h, (-A[i]-B[j]-C[k+1], i, j, k+1))
        used.add((i, j, k+1))

for v in result:
    print(v)
# Original solution
# coding: utf-8
import sys
from bisect import bisect_left, bisect_right
import itertools
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 二分探索, 大きい方から１つずつheapに入れる、XとYは全探索
# AとBは全探索
X, Y, Z, K = lr()
A = lr(); A.sort()
B = lr(); B.sort()
C = lr(); C.sort()
D = []
for a, b in itertools.product(A, B):
    D.append(a+b)
D.sort()

def check(x):
    length = len(D)
    count = 0
    for y in C:
        i = bisect_left(D, x-y)
        count += length - i
    return count >= K

ok = 0; ng = 10 ** 11
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

# ok以上の値
answer = []
for y in C:
    index = bisect_left(D, ok-y)
    for i in range(index, len(D)):
        heappush(answer, -(D[i]+y))

for i in range(K):
    print((-heappop(answer)))

# 02

# Optimized solution
# coding: utf-8
import sys
from bisect import bisect_left, bisect_right
import itertools
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# AとBは全探索、その後二分探索
X, Y, Z, K = lr()
A = lr(); A.sort()
B = lr(); B.sort()
C = lr(); C.sort()
D = []
for a, b in itertools.product(A, B):
    D.append(a+b)
D.sort()
if len(D) > K:
    D = D[-K:]

def check(x):
    length = len(D)
    count = 0
    for y in C:
        i = bisect_left(D, x-y)
        count += length - i
    return count >= K

ok = 0; ng = 10 ** 11
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

# ok以上の値
answer = []
for y in C:
    index = bisect_left(D, ok-y)
    for i in range(index, len(D)):
        heappush(answer, -(D[i]+y))

for i in range(K):
    print((-heappop(answer)))

# 02
# Original solution
# coding: utf-8
import sys
from bisect import bisect_left, bisect_right
import itertools
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# AとBは全探索、その後二分探索
X, Y, Z, K = lr()
A = lr(); A.sort()
B = lr(); B.sort()
C = lr(); C.sort()
D = []
for a, b in itertools.product(A, B):
    D.append(a+b)
D.sort()
if len(D) > K:
    D = D[-K:]

def check(x):
    length = len(D)
    count = 0
    for y in C:
        i = bisect_left(D, x-y)
        count += length - i
    return count >= K

ok = 0; ng = 10 ** 11
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

# ok以上の値
answer = []
for y in C:
    index = bisect_left(D, ok-y)
    for i in range(index, len(D)):
        heappush(answer, -(D[i]+y))

for i in range(K):
    print((-heappop(answer)))

# 02

# Optimized solution
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 虫の目、一個ずつheapへ
X, Y, Z, K = lr()
A = lr(); A.sort(reverse=True)
B = lr(); B.sort(reverse=True)
C = lr(); C.sort(reverse=True)

ma = A[0] + B[0] + C[0]
heap = [(-ma, (0, 0, 0))]
used = set()
for _ in range(K):
    result, place = heappop(heap)
    print((-result))
    i, j, k = place
    p = (i+1, j, k)
    if i + 1 < len(A) and p not in used:
        val = A[i+1] + B[j] + C[k]
        used.add(p)
        heappush(heap, (-val, p))
    p = (i, j+1, k)
    if j + 1 < len(B) and p not in used:
        val = A[i] + B[j+1] + C[k]
        used.add(p)
        heappush(heap, (-val, p))
    p = (i, j, k+1)
    if k + 1 < len(C) and p not in used:
        val = A[i] + B[j] + C[k+1]
        used.add(p)
        heappush(heap, (-val, p))

# 26
# Original solution
from itertools import product

x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = [ai + bi for (ai, bi) in product(a, b)]
ab.sort(reverse=True)
abc = [abi + ci for (abi, ci) in product(ab[: min(k, x * y * z)], c)]
abc.sort(reverse=True)

for abci in abc[: min(k, x * y * z)]:
    print(abci)


# Optimized solution
from itertools import product

x, y, z, k = list(map(int, input().split()))
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

ab = [ai + bi for (ai, bi) in product(a[:k], b[:k])]
ab.sort(reverse=True)
abc = [abi + ci for (abi, ci) in product(ab[: min(k, x * y * z)], c[:k])]
abc.sort(reverse=True)

for abci in abc[: min(k, x * y * z)]:
    print(abci)
# Original solution
import heapq

x, y, z, k =  list(map(int,input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

hq = [[-a[0]-b[0]-c[0], 0, 0, 0]]
heapq.heapify(hq)
visited = [[[0] * z for yy in range(y)] for xx in range(x)]
for i in range(k):
    ii, ia, ib, ic = heapq.heappop(hq)
    print((-ii))
    na = min(ia+1, x-1)
    nb = min(ib+1, y-1)
    nc = min(ic+1, z-1)
    if visited[na][ib][ic] == 0:
        heapq.heappush(hq, [-a[na] -b[ib] -c[ic], na, ib, ic])
        visited[na][ib][ic] = 1
    if visited[ia][nb][ic] == 0:
        heapq.heappush(hq, [-a[ia] -b[nb] -c[ic], ia, nb, ic])
        visited[ia][nb][ic] = 1
    if visited[ia][ib][nc] == 0:
        heapq.heappush(hq, [-a[ia] -b[ib] -c[nc], ia, ib, nc])
        visited[ia][ib][nc] = 1

# Optimized solution
import heapq

x, y, z, k =  list(map(int,input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

hq = [[-a[0]-b[0]-c[0], 0, 0, 0]]
heapq.heapify(hq)
visited = {(0,0,0)}

for i in range(k):
    ii, ia, ib, ic = heapq.heappop(hq)
    print((-ii))
    na = min(ia+1, x-1)
    nb = min(ib+1, y-1)
    nc = min(ic+1, z-1)
    if not (na, ib, ic) in visited:
        heapq.heappush(hq, [-a[na] -b[ib] -c[ic], na, ib, ic])
        visited.add((na, ib, ic))
    if not (ia, nb, ic) in visited:
        heapq.heappush(hq, [-a[ia] -b[nb] -c[ic], ia, nb, ic])
        visited.add((ia, nb, ic))
    if not (ia, ib, nc) in visited:
        heapq.heappush(hq, [-a[ia] -b[ib] -c[nc], ia, ib, nc])
        visited.add((ia, ib, nc))
# Original solution
import heapq

X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sorted(A, reverse=True)
b = sorted(B, reverse=True)
c = sorted(C, reverse=True)

added = [(0, 0, 0)]
cakes = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
for k in range(K):
	v = heapq.heappop(cakes)
	print((-v[0]))
	va, vb, vc = v[1:]
	if va < X - 1 and (va + 1, vb, vc) not in added:
		heapq.heappush(cakes, (-(a[va + 1] + b[vb] + c[vc]), va + 1, vb, vc))
		added += [(va + 1, vb, vc)]
	if vb < Y - 1 and (va, vb + 1, vc) not in added:
		heapq.heappush(cakes, (-(a[va] + b[vb + 1] + c[vc]), va, vb + 1, vc))
		added += [(va, vb + 1, vc)]
	if vc < Z - 1 and (va, vb, vc + 1) not in added:
		heapq.heappush(cakes, (-(a[va] + b[vb] + c[vc + 1]), va, vb, vc + 1))
		added += [(va, vb, vc + 1)]


# Optimized solution
# データ構造：ヒープ
import heapq
class heapque:
    def __init__(self, *args):
        self.que = []
        for arg in args:
            self.push(arg)
    def push(self, v):
        heapq.heappush(self.que, v)
    def pop(self):
        return heapq.heappop(self.que)

# 定数
INF = float("inf")
MOD = int(1e9 + 7)

# エントリーポイント
def main():
    X, Y, Z, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    a = sorted(A, reverse=True)
    b = sorted(B, reverse=True)
    c = sorted(C, reverse=True)
    heap = heapque((-(a[0] + b[0] + c[0]), (0, 0, 0)))
    used = {(0, 0, 0)}
    for _ in range(K):
        cur = heap.pop()
        print((-cur[0]))

        ai, bi, ci = cur[1]
        ns = ((min(ai + 1, X - 1), bi, ci), (ai, min(bi + 1, Y - 1), ci), (ai, bi, min(ci + 1, Z - 1)))
        for n in ns:
            if n in used: continue
            heap.push((-(a[n[0]] + b[n[1]] + c[n[2]]), n))
            used |= {n}

main()
# Original solution
from bisect import bisect_left as bi
x,y,z,k=list(map(int,input().split()))
a=sorted(list(map(int,input().split())))[::-1]
b=sorted(list(map(int,input().split())))[::-1]
c=sorted(list(map(int,input().split())))[::-1]
for i in sorted([j+i for j in c for i in sorted([i+j for i in a for j in b])[::-1][:k]])[::-1][:k]:
    print(i)

# Optimized solution
x,y,z,k=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort(reverse=True)
b=list(map(int,input().split()))
b.sort(reverse=True)
c=list(map(int,input().split()))
c.sort(reverse=True)
d=[i+j for i in a for j in b]
d.sort(reverse=True)
e=[i+j for i in c for j in d[:k]]
e.sort(reverse=True)
for i in range(k):
    print((e[i]))
# Original solution
import math

x,y,z,k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

Ai= sorted(A, reverse=True)
Bi= sorted(B, reverse=True)
Ci= sorted(C, reverse=True)

def su(a,b,c):
	return(Ai[a]+Bi[b]+Ci[c])

a=0
b=0
c=0

pq=[[su(a,b,c),a,b,c]]
ck=[[su(a,b,c),a,b,c]]

dl=0
for i in range(k):
	dl=pq.index(max(pq))
	res=pq.pop(dl)
	print((res[0]))
	#print(pq)
	
	a=res[1]
	b=res[2]
	c=res[3]
	if a+1<=x-1 and (not [su(a+1,b,c),a+1,b,c] in ck):
		pq.append([su(a+1,b,c),a+1,b,c])
		ck.append([su(a+1,b,c),a+1,b,c])
	if b+1<=y-1 and (not [su(a,b+1,c),a,b+1,c] in ck):
		pq.append([su(a,b+1,c),a,b+1,c])
		ck.append([su(a,b+1,c),a,b+1,c])
	if c+1<=z-1 and (not [su(a,b,c+1),a,b,c+1] in ck):
		pq.append([su(a,b,c+1),a,b,c+1])
		ck.append([su(a,b,c+1),a,b,c+1])

# Optimized solution
import math

x,y,z,k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

Ai= sorted(A, reverse=True)
Bi= sorted(B, reverse=True)
Ci= sorted(C, reverse=True)

def su(a,b,c):
	return(Ai[a]+Bi[b]+Ci[c])

a=0
b=0
c=0

pq=[[su(a,b,c),a,b,c]]
ck=[a,b,c]

dl=0
for i in range(k):
	dl=pq.index(max(pq))
	res=pq.pop(dl)
	print((res[0]))

	a=res[1]
	b=res[2]
	c=res[3]
	if a+1<=x-1 and (not [a+1,b,c] in ck):
		pq.append([su(a+1,b,c),a+1,b,c])
		ck.append([a+1,b,c])
	if b+1<=y-1 and (not [a,b+1,c] in ck):
		pq.append([su(a,b+1,c),a,b+1,c])
		ck.append([a,b+1,c])
	if c+1<=z-1 and (not [a,b,c+1] in ck):
		pq.append([su(a,b,c+1),a,b,c+1])
		ck.append([a,b,c+1])
# Original solution
import itertools

x,y,z,k=(int(i) for i in input().split())
#print(x,y,z,k)
a=list(int(i) for i in input().split())
#a.sort(reverse=True)
b=list(int(i) for i in input().split())
#b.sort(reverse=True)
c=list(int(i) for i in input().split())
#c.sort(reverse=True)
#print(a,b,c)

#a=[int(i) for i in range(1000,-1,-1)]
#b=[int(i) for i in range(1000,-1,-1)]
#c=[int(i) for i in range(1000,-1,-1)]
x=list(itertools.product(a,b))
for i in range(len(x)):
  x[i]=x[i][0]+x[i][1]
x.sort(reverse=True)
y=[]
length=min(len(x),1600)
for i in range(length):
  y+=[x[i]]
#print(len(y))
y=list(itertools.product(y,c))
#print(y)
for i in range(len(y)):
  y[i]=y[i][0]+y[i][1]
y.sort(reverse=True)

for i in range(k):
  print((y[i]))


# Optimized solution
#import itertools

x,y,z,k=(int(i) for i in input().split())
#print(x,y,z,k)
a=list(int(i) for i in input().split())
a.sort(reverse=True)
b=list(int(i) for i in input().split())
b.sort(reverse=True)
c=list(int(i) for i in input().split())
c.sort(reverse=True)
#print(a,b,c)

#k=3000
#a=[int(i) for i in range(1000)]
#b=[int(i) for i in range(1000)]
#c=[int(i) for i in range(1000)]
x=[]
for h in range(len(a)):
    for i in range(len(b)):
        if (h+1)*(i+1) <=k:
            for j in range(len(c)):
                if (h+1)*(i+1)*(j+1) <=k:
                    x.append(a[h]+b[i]+c[j])

x.sort(reverse=True)
for i in range(k):
  print((x[i]))
# Original solution
import heapq
import itertools

x,y,z,k=(int(i) for i in input().split())
#print(x,y,z,k)
a=list((-1)*int(i) for i in input().split())
#a.sort(reverse=True)
b=list((-1)*int(i) for i in input().split())
#b.sort(reverse=True)
c=list((-1)*int(i) for i in input().split())
#c.sort(reverse=True)
#print(a,b,c)

mylist=list(itertools.product(a,b,c))
#print(mylist)
mylist=[sum(mylist[i]) for i in range(len(mylist))]
#print(mylist)

def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(k)]

#    return [heapq.heappop(h) for i in range(len(h))]

#heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])
mylist1=heapsort(mylist)

for i in range(k):
  print(((-1)*mylist1[i]))
  

# Optimized solution
#from collections import deque
#import copy

x,y,z,ansk=(int(i) for i in input().split())
#print(x,y,z,k)

a=list(int(i) for i in input().split())
a.sort(reverse=True)
b=list(int(i) for i in input().split())
b.sort(reverse=True)
c=list(int(i) for i in input().split())
c.sort(reverse=True)
#print(a,b,c)

mylist=[0 for i in range(x*y)]
k=0
for i in range(x):
  for j in range(y):
    mylist[k]=a[i]+b[j]
    k+=1
mylist.sort(reverse=True)
#print(mylist)

k=0
mylist1=[0 for i in range(x*y*z)]
for i in range(x*y):
  for j in range(z):
    mylist1[k]=mylist[i]+c[j]
    k+=1
mylist1.sort(reverse=True)

for i in range(ansk):
  print((mylist1[i]))
# Original solution
#from collections import deque
#import copy

x,y,z,ansk=(int(i) for i in input().split())
#print(x,y,z,k)

a=list(int(i) for i in input().split())
a.sort(reverse=True)
b=list(int(i) for i in input().split())
b.sort(reverse=True)
c=list(int(i) for i in input().split())
c.sort(reverse=True)
#print(a,b,c)

l=0
mylist=[0 for i in range(x*y*z)]
for i in range(x):
  for j in range(y):
    if (i+1)*(j+1) <= ansk:
      for k in range(z):
        if (i+1)*(j+1)*(k+1) <= ansk:      
          mylist[l]=a[i]+b[j]+c[k]
          l+=1
mylist.sort(reverse=True)

#print(mylist)

for i in range(ansk):
  print((mylist[i]))



# Optimized solution
x,y,z,k=(int(i) for i in input().split())
#print(x,y,z,k)
a=list(int(i) for i in input().split())
a.sort(reverse=True)
b=list(int(i) for i in input().split())
b.sort(reverse=True)
c=list(int(i) for i in input().split())
c.sort(reverse=True)
#print(a,b,c)

#k=3000
#a=[int(i) for i in range(1000)]
#b=[int(i) for i in range(1000)]
#c=[int(i) for i in range(1000)]
x=[]
for h in range(len(a)):
    for i in range(len(b)):
        if (h+1)*(i+1) <=k:
            for j in range(len(c)):
                if (h+1)*(i+1)*(j+1) <=k:
                    x.append(a[h]+b[i]+c[j])

x.sort(reverse=True)
for i in range(k):
  print((x[i]))