The Patisserie AtCoder sells cakes with number-shaped candles.
There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.
Each cake has an integer value called deliciousness, as follows:
 - The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.
 - The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.
 - The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.
Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.

There are X \times Y \times Z such ways to choose three cakes.

We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes.

Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.

-----Constraints-----
 - 1 \leq X \leq 1 \ 000
 - 1 \leq Y \leq 1 \ 000
 - 1 \leq Z \leq 1 \ 000
 - 1 \leq K \leq \min(3 \ 000, X \times Y \times Z)
 - 1 \leq A_i \leq 10 \ 000 \ 000 \ 000
 - 1 \leq B_i \leq 10 \ 000 \ 000 \ 000
 - 1 \leq C_i \leq 10 \ 000 \ 000 \ 000
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
X Y Z K
A_1 \ A_2 \ A_3 \ ... \ A_X
B_1 \ B_2 \ B_3 \ ... \ B_Y
C_1 \ C_2 \ C_3 \ ... \ C_Z

-----Output-----
Print K lines. The i-th line should contain the i-th value stated in the problem statement.

-----Sample Input-----
2 2 2 8
4 6
1 5
3 8

-----Sample Output-----
19
17
15
14
13
12
10
8

There are 2 \times 2 \times 2 = 8 ways to choose three cakes, as shown below in descending order of the sum of the deliciousness of the cakes:
 - (A_2, B_2, C_2): 6 + 5 + 8 = 19
 - (A_1, B_2, C_2): 4 + 5 + 8 = 17
 - (A_2, B_1, C_2): 6 + 1 + 8 = 15
 - (A_2, B_2, C_1): 6 + 5 + 3 = 14
 - (A_1, B_1, C_2): 4 + 1 + 8 = 13
 - (A_1, B_2, C_1): 4 + 5 + 3 = 12
 - (A_2, B_1, C_1): 6 + 1 + 3 = 10
 - (A_1, B_1, C_1): 4 + 1 + 3 = 8

Difficulty: MEDIUM

Solutions:
(X, Y, Z, K) = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
l = []
for a in A:
	for b in B:
		l.append(a + b)
l = sorted(l, reverse=True)[:K]
ans = []
for c in C:
	for k in l:
		ans.append(c + k)
ans = sorted(ans, reverse=True)
print(*ans[:K], sep='\n')


(x, y, z, K) = 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=1)
b.sort(reverse=1)
c.sort(reverse=1)
m = []
for i in range(x):
	for j in range(y):
		for k in range(z):
			if (i + 1) * (j + 1) * (k + 1) > K:
				break
			m.append(a[i] + b[j] + c[k])
m.sort(reverse=1)
for i in m[:K]:
	print(i)


import itertools
(X, Y, Z, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for (a, b) in itertools.product(A, B)]
AB.sort(reverse=True)
AB = AB[:K]
ABC = [ab + c for (ab, c) in itertools.product(AB, C)]
ABC.sort(reverse=True)
for i in range(K):
	print(ABC[i])


(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)
cakeList = []
for i in range(1, X + 1):
	for j in range(1, Y + 1):
		for k in range(1, Z + 1):
			if i * j * k <= K:
				cakeList.append(A[i - 1] + B[j - 1] + C[k - 1])
			else:
				break
cakeList.sort(reverse=True)
for i in range(K):
	print(cakeList[i])


(X, Y, Z, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
AB = []
for a in A:
	for b in B:
		AB.append(a + b)
AB.sort(reverse=True)
AB = AB[0:K]
C = list(map(int, input().split()))
ABC = []
for ab in AB:
	for c in C:
		ABC.append(ab + c)
ABC.sort(reverse=True)
for i in range(K):
	print(ABC[i])


(x, y, z, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
lis = []
for i in a:
	for j in b:
		lis.append(i + j)
lis.sort(reverse=True)
ab = lis[:k]
kouho = []
for sm in ab:
	for tmp in c:
		kouho.append(sm + tmp)
kouho.sort(reverse=True)
kouho = kouho[:k]
for ans in kouho:
	print(ans)


import sys
input = sys.stdin.readline
(x, y, z, k) = 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)
l1 = sorted([i + j for i in a for j in b], reverse=True)[:k]
l2 = sorted([i + j for i in l1 for j in c], reverse=True)[:k]
for i in l2:
	print(i)


(X, Y, Z, K) = 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)
ABC = []
for x in range(X):
	for y in range(Y):
		for z in range(Z):
			if (x + 1) * (y + 1) * (z + 1) <= K:
				ABC.append(A[x] + B[y] + C[z])
			else:
				break
ABC.sort(reverse=True)
for i in range(K):
	print(ABC[i])


(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)
ans = []
for i in range(x):
	for j in range(y):
		for l in range(z):
			if (i + 1) * (j + 1) * (l + 1) <= k:
				ans.append(a[i] + b[j] + c[l])
			else:
				break
ans.sort(reverse=True)
for i in range(k):
	print(ans[i])


import sys
input = sys.stdin.readline
(X, Y, Z, K) = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = (aa + bb for aa in a for bb in b)
d = sorted(d, reverse=True)[:K]
e = (cc + dd for cc in c for dd in d)
e = sorted(e, reverse=True)[:K]
print('\n'.join(map(str, e)))


from heapq import nlargest
(x, y, z, k) = map(int, input().split())
(A, B, C) = [list(map(int, input().split())) for _ in [0] * 3]
AB = nlargest(k, [a + b for a in A for b in B])
ABC = nlargest(k, [ab + c for ab in AB for c in C])
print('\n'.join(map(str, ABC)))


from heapq import heappop, heappush
(X, Y, Z, K) = 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)
l = []
for a in A:
	for b in B:
		l.append(-a - b)
l.sort()
l = l[:K] if len(l) >= K else l + [0] * (K - len(l))
ans = []
for c in C:
	for i in l:
		heappush(ans, i - c)
for i in range(K):
	print(-heappop(ans))


(X, Y, Z, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()), reverse=True)
AB = []
for a in A:
	for b in B:
		AB.append(a + b)
AB.sort(reverse=True)
ans = []
for ab in AB[:K]:
	for c in C:
		ans.append(ab + c)
ans.sort(reverse=True)
print(*ans[:K], sep='\n')


import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
(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)
(i, j, k) = (0, 0, 0)
heap = [(-A[i] - B[j] - C[k], i, j, k)]
heapq.heapify(heap)
used_set = set([(i, j, k)])
for _ in range(K):
	(oisi, i, j, k) = heapq.heappop(heap)
	print(-oisi)
	if (i + 1, j, k) in used_set:
		pass
	elif i + 1 < len(A):
		used_set.add((i + 1, j, k))
		heapq.heappush(heap, (-A[i + 1] - B[j] - C[k], i + 1, j, k))
	if (i, j + 1, k) in used_set:
		pass
	elif j + 1 < len(B):
		used_set.add((i, j + 1, k))
		heapq.heappush(heap, (-A[i] - B[j + 1] - C[k], i, j + 1, k))
	if (i, j, k + 1) in used_set:
		pass
	elif k + 1 < len(C):
		used_set.add((i, j, k + 1))
		heapq.heappush(heap, (-A[i] - B[j] - C[k + 1], i, j, k + 1))


from heapq import heappop, heappush
(X, Y, Z, K) = list(map(int, input().split()))
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
a_list.sort(reverse=True)
b_list.sort(reverse=True)
c_list.sort(reverse=True)
hq = []
arg_hash = {}
val = -(a_list[0] + b_list[0] + c_list[0])
heappush(hq, (val, 0, 0, 0))
ans_arr = []
for i in range(K):
	(ans_val, p, q, r) = heappop(hq)
	ans_arr.append(-ans_val)
	arg_a = (p + 1, q, r)
	arg_b = (p, q + 1, r)
	arg_c = (p, q, r + 1)
	if p < X - 1 and arg_a not in arg_hash:
		arg_hash[arg_a] = 1
		heappush(hq, (-(a_list[p + 1] + b_list[q] + c_list[r]),) + arg_a)
	if q < Y - 1 and arg_b not in arg_hash:
		arg_hash[arg_b] = 1
		heappush(hq, (-(a_list[p] + b_list[q + 1] + c_list[r]),) + arg_b)
	if r < Z - 1 and arg_c not in arg_hash:
		arg_hash[arg_c] = 1
		heappush(hq, (-(a_list[p] + b_list[q] + c_list[r + 1]),) + arg_c)
for i in range(len(ans_arr)):
	print(ans_arr[i])


import numpy as np

def main():
	(X, Y, Z, K) = list(map(int, input().split(' ')))
	A = np.array(list(map(int, input().split(' '))))
	B = np.array(list(map(int, input().split(' '))))
	C = np.array(list(map(int, input().split(' '))))
	AB = np.array(np.meshgrid(A, B)).T.reshape(-1, 2).sum(axis=1)
	AB[::-1].sort()
	AB = AB[:min([K, X * Y])]
	ABC = np.array(np.meshgrid(AB, C)).T.reshape(-1, 2).sum(axis=1)
	ABC[::-1].sort()
	for ans in ABC[:K]:
		print(ans)

def __starting_point():
	main()
__starting_point()


import heapq
(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)
checked = {(0, 0, 0)}
h = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]

def push(i, j, k):
	if i < X and j < Y and (k < Z) and ((i, j, k) not in checked):
		heapq.heappush(h, (-(A[i] + B[j] + C[k]), i, j, k))
		checked.add((i, j, k))
for _ in range(K):
	(s, i, j, k) = heapq.heappop(h)
	print(-s)
	push(i + 1, j, k)
	push(i, j + 1, k)
	push(i, j, k + 1)


import heapq

def submit():
	(x, y, z, k) = 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)

	def get(i, j, k):
		return (a[i] + b[j] + c[k], (i, j, k))
	check = set()
	check.add((0, 0, 0))
	ans = [get(0, 0, 0)]
	q = []
	for _ in range(k - 1):
		(prev, (i, j, k)) = ans[-1]
		if i < x - 1:
			new_triple = (i + 1, j, k)
			if new_triple not in check:
				check.add(new_triple)
				(s, _) = get(*new_triple)
				heapq.heappush(q, (-s, new_triple))
		if j < y - 1:
			new_triple = (i, j + 1, k)
			if new_triple not in check:
				check.add(new_triple)
				(s, _) = get(*new_triple)
				heapq.heappush(q, (-s, new_triple))
		if k < z - 1:
			new_triple = (i, j, k + 1)
			if new_triple not in check:
				check.add(new_triple)
				(s, _) = get(*new_triple)
				heapq.heappush(q, (-s, new_triple))
		(next_s, next_triple) = heapq.heappop(q)
		ans.append((-next_s, next_triple))
	for (s, _) in ans:
		print(s)
submit()


from heapq import heappush, heapify, heappop

def main():
	(X, Y, Z, K) = 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)
	que = []
	heapify(que)
	heappush(que, (-A[0] - B[0] - C[0], 0, 0, 0))
	s = set()
	for i in range(K):
		ans = heappop(que)
		print(-ans[0])
		if ans[1] < X - 1 and (not (ans[1] + 1, ans[2], ans[3]) in s):
			heappush(que, [-A[ans[1] + 1] - B[ans[2]] - C[ans[3]], ans[1] + 1, ans[2], ans[3]])
			s.add((ans[1] + 1, ans[2], ans[3]))
		if ans[2] < Y - 1 and (not (ans[1], ans[2] + 1, ans[3]) in s):
			heappush(que, [-A[ans[1]] - B[ans[2] + 1] - C[ans[3]], ans[1], ans[2] + 1, ans[3]])
			s.add((ans[1], ans[2] + 1, ans[3]))
		if ans[3] < Z - 1 and (not (ans[1], ans[2], ans[3] + 1) in s):
			heappush(que, [-A[ans[1]] - B[ans[2]] - C[ans[3] + 1], ans[1], ans[2], ans[3] + 1])
			s.add((ans[1], ans[2], ans[3] + 1))
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)
a_max = min(k, len(a))
b_max = min(k, len(b))
c_max = min(k, len(c))
abc = []
for i in range(1, k + 1):
	if i > len(a):
		break
	for j in range(1, k // i + 1):
		if j > len(b):
			break
		for l in range(1, k // (i * j) + 1):
			if l > len(c):
				break
			abc.append(a[i - 1] + b[j - 1] + c[l - 1])
abc.sort(reverse=True)
for i in range(k):
	print(abc[i])


(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(min(X, K)):
	D = int(K / (i + 1)) + 1
	for j in range(min(D, Y, K)):
		E = int(D / (j + 1)) + 1
		for k in range(min(E, Z, K)):
			ans.append(A[i] + B[j] + C[k])
ans.sort(reverse=True)
for i in range(K):
	print(ans[i])


(x, y, z, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ab = sorted([s + t for s in a for t in b])[-1:-k - 1:-1]
abc = sorted([s + t for s in ab for t in c])[-1:-k - 1:-1]
for i in range(k):
	print(abc[i])


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))


(X, Y, Z, K) = map(int, input().split())
(*A,) = map(int, input().split())
(*B,) = map(int, input().split())
(*C,) = map(int, input().split())
A.sort(reverse=True)
D = [i + j for j in C for i in B]
D.sort(reverse=True)
E = [i + j for j in D[:K] for i in A[:K]]
E.sort(reverse=True)
print(*E[:K], sep='\n')


def main():
	import heapq
	(x, y, z, k, *abc) = map(int, open(0).read().split())
	a = abc[:x]
	b = abc[x:x + y]
	c = abc[x + y:]
	s = set()
	a.sort(reverse=True)
	b.sort(reverse=True)
	c.sort(reverse=True)
	h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
	heapq.heapify(h)
	ans = []
	for _ in range(k):
		(p, i, j, k) = heapq.heappop(h)
		ans.append(-p)
		for (p, q, r) in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
			if i + p < x and j + q < y and (k + r < z):
				if (i + p, j + q, k + r) not in s:
					s.add((i + p, j + q, k + r))
					v = -(a[i + p] + b[j + q] + c[k + r])
					heapq.heappush(h, (v, i + p, j + q, k + r))
	print(*ans, sep='\n')

def __starting_point():
	main()
__starting_point()


from heapq import nlargest
(x, y, z, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ab = nlargest(k, (x + y for x in a for y in b))
abc = nlargest(k, (xy + z for xy in ab for z in c))
for i in abc:
	print(i)


(x, y, z, K) = map(int, input().split())
abc = [sorted(list(map(int, input().split())), reverse=True) for i in range(3)]
ans = []
for i in range(x):
	for j in range(y):
		for k in range(z):
			if (i + 1) * (j + 1) * (k + 1) <= K:
				ans.append(abc[0][i] + abc[1][j] + abc[2][k])
			else:
				break
for i in sorted(ans)[::-1][:K]:
	print(i)


from heapq import *
(x, y, z, K) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))[::-1]
d = sorted([q + p for q in a for p in b], reverse=True)[:K]
e = sorted([q + p for q in d for p in c], reverse=True)[:K]
for i in e:
	print(i)


(X, Y, Z, K) = list(map(int, input().split()))
l_A = list(map(int, input().split()))
l_B = list(map(int, input().split()))
l_C = list(map(int, input().split()))
l_A.sort(reverse=True)
l_B.sort(reverse=True)
l_C.sort(reverse=True)
l = []
for i in range(len(l_A)):
	for j in range(len(l_B)):
		for k in range(len(l_C)):
			if (i + 1) * (j + 1) * (k + 1) > K:
				break
			l += [l_A[i] + l_B[j] + l_C[k]]
ans = sorted(l, reverse=True)[:K]
print(*ans, sep='\n')


import heapq
(x, y, z, k) = 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)
li = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
heapq.heapify(li)
for i in range(k):
	ans = heapq.heappop(li)
	print(-ans[0])
	if x > ans[1] + 1 and (-(a[ans[1] + 1] + b[ans[2]] + c[ans[3]]), ans[1] + 1, ans[2], ans[3]) not in li:
		heapq.heappush(li, (-(a[ans[1] + 1] + b[ans[2]] + c[ans[3]]), ans[1] + 1, ans[2], ans[3]))
	if y > ans[2] + 1 and (-(a[ans[1]] + b[ans[2] + 1] + c[ans[3]]), ans[1], ans[2] + 1, ans[3]) not in li:
		heapq.heappush(li, (-(a[ans[1]] + b[ans[2] + 1] + c[ans[3]]), ans[1], ans[2] + 1, ans[3]))
	if z > ans[3] + 1 and (-(a[ans[1]] + b[ans[2]] + c[ans[3] + 1]), ans[1], ans[2], ans[3] + 1) not in li:
		heapq.heappush(li, (-(a[ans[1]] + b[ans[2]] + c[ans[3] + 1]), ans[1], ans[2], ans[3] + 1))


import copy
num_list = list(map(int, input('').split(' ')))
rank = num_list[3]
lists = []
queue = []
for i in range(3):
	a_list = list(map(int, input('').split(' ')))
	list.sort(a_list, reverse=True)
	if num_list[i] <= rank:
		lists.append(a_list)
	else:
		lists.append(a_list[:rank])
queue.append([lists[0][0] + lists[1][0] + lists[2][0], 0, 0, 0])
for i in range(rank):
	poped = queue.pop(0)
	print(poped[0])
	if i == rank - 1:
		break
	for j in range(3):
		if len(lists[j]) > poped[j + 1] + 1:
			to_append = copy.copy(poped)
			to_append[j + 1] += 1
			to_append[0] += lists[j][to_append[j + 1]] - lists[j][poped[j + 1]]
			if len(queue) == 0:
				queue.append(to_append)
				continue
			Done = True
			for k in range(len(queue)):
				if queue[k] == to_append:
					Done = False
					break
				elif queue[k][0] < to_append[0]:
					queue = queue[:k] + [to_append] + queue[k:]
					Done = False
					break
			if Done == True:
				queue.append(to_append)
	if len(queue) > rank - i - 1:
		queue = queue[:rank - i - 1]


from heapq import *
(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)
Q = []
his = set()

def pushq(p, q, r):
	if (p, q, r) in his:
		return
	if p >= X or q >= Y or r >= Z:
		return
	his.add((p, q, r))
	heappush(Q, (-1 * (A[p] + B[q] + C[r]), (p, q, r)))
	return
pushq(0, 0, 0)
for _ in range(K):
	V = heappop(Q)
	print(-1 * V[0])
	(p, q, r) = V[1]
	pushq(p + 1, q, r)
	pushq(p, q + 1, r)
	pushq(p, q, r + 1)


(X, Y, Z, K) = 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)
K = min(K, 3000)
AB = [a + b for a in A for b in B]
AB.sort(reverse=True)
ABC = [ab + c for ab in AB[:K] for c in C[:K]]
ABC.sort(reverse=True)
for k in range(K):
	print(ABC[k])


(X, Y, Z, K) = 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)
ans = []
for i in range(X):
	for j in range(Y):
		ij = (i + 1) * (j + 1)
		if ij > K:
			break
		for k in range(Z):
			if ij * (k + 1) > K:
				break
			ans.append(A[i] + B[j] + C[k])
ans = sorted(ans, reverse=True)
for i in range(K):
	print(ans[i])


(x, y, z, k) = 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)
ab = sorted((i + j for i in a for j in b))[:-k - 1:-1]
c = c[:k]
abc = sorted((i + j for i in ab for j in c))[:-k - 1:-1]
print(*abc[:k], sep='\n')


def main():
	import heapq
	from collections import defaultdict
	(x, y, z, k, *abc) = map(int, open(0).read().split())
	a = abc[:x]
	b = abc[x:x + y]
	c = abc[x + y:]
	d = defaultdict(list)
	a.sort(reverse=True)
	b.sort(reverse=True)
	c.sort(reverse=True)
	h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
	heapq.heapify(h)
	ans = []
	for _ in range(k):
		(p, i, j, k) = heapq.heappop(h)
		ans.append(-p)
		for (p, q, r) in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
			if i + p < x and j + q < y and (k + r < z):
				if (j + q, k + r) not in d[i + p]:
					d[i + p].append((j + q, k + r))
					v = -(a[i + p] + b[j + q] + c[k + r])
					heapq.heappush(h, (v, i + p, j + q, k + r))
	print(*ans, sep='\n')

def __starting_point():
	main()
__starting_point()


(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]
ans = []
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
			ans.append(a[i] + b[j] + c[k])
ans = sorted(ans)[::-1]
for i in range(K):
	print(ans[i])


import heapq
(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)
que = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
is_pushed = {(0, 0, 0): 1}
for _ in range(k):
	(v, p, q, r) = heapq.heappop(que)
	print(-v)
	if p + 1 < x and (not is_pushed.get((p + 1, q, r))):
		heapq.heappush(que, (-(a[p + 1] + b[q] + c[r]), p + 1, q, r))
		is_pushed[p + 1, q, r] = 1
	if q + 1 < y and (not is_pushed.get((p, q + 1, r))):
		heapq.heappush(que, (-(a[p] + b[q + 1] + c[r]), p, q + 1, r))
		is_pushed[p, q + 1, r] = 1
	if r + 1 < z and (not is_pushed.get((p, q, r + 1))):
		heapq.heappush(que, (-(a[p] + b[q] + c[r + 1]), p, q, r + 1))
		is_pushed[p, q, r + 1] = 1


(x, y, z, k) = 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]
d = []
for i in a:
	for j in b:
		d += [i + j]
ans = []
d = sorted(d)[::-1][:k]
for i in c:
	for j in d:
		ans += [i + j]
print(*sorted(ans)[::-1][:k], sep='\n')


from itertools import product
(x, y, z, k) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
D = sorted([a + b for (a, b) in product(A, B)], reverse=True)[:k]
E = sorted([c + d for (c, d) in product(C, D)], reverse=True)[:k]
[print(ans) for ans in E]


from heapq import nlargest
(X, Y, Z, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
E = nlargest(K, [a + b for a in A for b in B])
F = nlargest(K, [e + c for e in E for c in C])
print('\n'.join(map(str, F)))


(x, y, z, k) = 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])


(X, Y, Z, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for a in A for b in B]
AB.sort()
AB = AB[-K:]
ABC = [ab + c for ab in AB for c in C]
ABC.sort()
for v in ABC[-1:-K - 1:-1]:
	print(v)


(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)
E = sorted([a + b for a in A for b in B], reverse=True)
E = E[:K]
nums = sorted([e + c for e in E for c in C], reverse=True)
for n in nums[:K]:
	print(n)


(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()))
C = sorted(C, reverse=True)
AB = sorted([a + b for a in A for b in B], reverse=True)
ABC_k = sorted([ab + c for ab in AB[:K] for c in C], reverse=True)
for ans in ABC_k[:K]:
	print(ans)


(x, y, z, K) = list(map(int, input().split()))
A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)
ans = []
for i in range(x):
	for j in range(y):
		for k in range(z):
			if (i + 1) * (j + 1) * (k + 1) <= K:
				ans.append(A[i] + B[j] + C[k])
				continue
			break
ans.sort(reverse=True)
for i in range(K):
	print(ans[i])


import sys
import math
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().strip()
NI = lambda : int(input())
NMI = lambda : map(int, input().split())
NLI = lambda : list(NMI())
SI = lambda : input()

def make_grid(h, w, num):
	return [[int(num)] * w for _ in range(h)]

def main():
	(X, Y, Z, K) = NMI()
	A = NLI()
	B = NLI()
	C = NLI()
	AB = []
	for a in A:
		for b in B:
			AB.append(a + b)
	AB.sort(reverse=True)
	C.sort(reverse=True)
	S = []
	for c_idx in range(min(len(C), 3000)):
		for ab_idx in range(min(len(AB), 3000)):
			S.append(C[c_idx] + AB[ab_idx])
	S.sort(reverse=True)
	for i in range(K):
		print(S[i])

def __starting_point():
	main()
__starting_point()


from heapq import heappop, heappush
import sys
input = sys.stdin.readline
(x, y, z, k) = map(int, input().split())
(a, b, c) = (list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())))
(q, h, l) = ([], [], 0)
for i in a:
	for j in b:
		heappush(q, -(i + j))
		l += 1
for _ in range(min(l, k)):
	t = heappop(q)
	for i in c:
		heappush(h, t - i)
for i in range(k):
	print(-heappop(h))


(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)
ans = []
for ai in a:
	for bi in b:
		ans.append(-ai - bi)
ans.sort()
ans = ans[:k] if len(ans) >= k else ans + [0] * (k - len(ans))
ans1 = []
from heapq import heapify, heappop, heappush
for ci in c:
	for ansi in ans:
		heappush(ans1, ansi - ci)
for i in range(k):
	print(-heappop(ans1))


from heapq import heappush, heappop
from collections import defaultdict

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)
	que = [(-A[0] - B[0] - C[0], 0, 0, 0)]
	already_inserted = defaultdict(int)
	answer = list()
	for _ in range(K):
		(q, i, j, k) = heappop(que)
		answer.append(-q)
		if i + 1 < X:
			item_a = (-A[i + 1] - B[j] - C[k], i + 1, j, k)
			if already_inserted[item_a] == 0:
				heappush(que, item_a)
				already_inserted[item_a] = 1
		if j + 1 < Y:
			item_b = (-A[i] - B[j + 1] - C[k], i, j + 1, k)
			if already_inserted[item_b] == 0:
				heappush(que, item_b)
				already_inserted[item_b] = 1
		if k + 1 < Z:
			item_c = (-A[i] - B[j] - C[k + 1], i, j, k + 1)
			if already_inserted[item_c] == 0:
				heappush(que, item_c)
				already_inserted[item_c] = 1
	for ans in answer:
		print(ans)

def __starting_point():
	main()
__starting_point()


import heapq
(X, Y, Z, K) = [int(x) for x in input().split()]
XYZ = [0] * 3
for i in range(3):
	XYZ[i] = [int(x) for x in input().split()]
	XYZ[i].sort(reverse=True)
tmp = (-1 * (XYZ[0][0] + XYZ[1][0] + XYZ[2][0]), 0, 0, 0)
q = [tmp]
inq = {tmp[1:]}
heapq.heapify(q)
for ik in range(K):
	max = heapq.heappop(q)
	print(-max[0])
	(i, j, k) = (max[1], max[2], max[3])
	if not (i + 1, j, k) in inq and i + 1 < X:
		heapq.heappush(q, (-1 * (XYZ[0][i + 1] + XYZ[1][j] + XYZ[2][k]), i + 1, j, k))
		inq.add((i + 1, j, k))
	if not (i, j + 1, k) in inq and j + 1 < Y:
		heapq.heappush(q, (-1 * (XYZ[0][i] + XYZ[1][j + 1] + XYZ[2][k]), i, j + 1, k))
		inq.add((i, j + 1, k))
	if not (i, j, k + 1) in inq and k + 1 < Z:
		heapq.heappush(q, (-1 * (XYZ[0][i] + XYZ[1][j] + XYZ[2][k + 1]), i, j, k + 1))
		inq.add((i, j, k + 1))
print()


import heapq
(X, Y, Z, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = []
for i in A:
	for j in B:
		heapq.heappush(AB, -i - j)
ABC = []
for i in range(min(K, X * Y)):
	temp = heapq.heappop(AB)
	for j in C:
		heapq.heappush(ABC, temp - j)
for i in range(min(K, X * Y * Z)):
	print(-heapq.heappop(ABC))


(x, y, z, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
ab = [a[i] + b[j] for j in range(y) for i in range(x)]
ab.sort(reverse=True)
ab = ab[:k]
l = len(ab)
abc = [ab[i] + c[j] for j in range(z) for i in range(l)]
abc.sort(reverse=True)
for i in range(k):
	print(abc[i])


(X, Y, Z, K) = map(int, input().split())
(A, B, C) = [sorted(list(map(int, input().split())))[::-1][:K] for _ in range(3)]
D = []
for ai in A:
	for bi in B:
		D.append(ai + bi)
D = sorted(D)[::-1][:K]
res = []
for di in D:
	for ci in C:
		res.append(di + ci)
res = sorted(res)[::-1][:K]
for ans in res:
	print(ans)


(X, Y, X, K) = 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)
ab = [a + b for a in A for b in B]
ab.sort(reverse=True)
ans = [x + c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(map(str, ans[:K])))


from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge

def solve():
	(X, Y, Z, K) = 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)
	Cake = []
	heapify(Cake)
	for i in range(X):
		for j in range(min(Y, K // (i + 1) + 1)):
			for k in range(min(Z, K // ((i + 1) * (j + 1)) + 1)):
				heappush(Cake, -A[i] - B[j] - C[k])
	ans = []
	for i in range(K):
		ans.append(abs(heappop(Cake)))
	return ans
print(*solve(), sep='\n')


(x, y, z, q) = map(int, input().split())
a = sorted(map(int, input().split()), reverse=True)
b = sorted(map(int, input().split()), reverse=True)
c = sorted(map(int, input().split()), reverse=True)
l = []
for i in range(x):
	for j in range(y):
		if i * j > q:
			break
		for k in range(z):
			if i * j * k > q:
				break
			l += [a[i] + b[j] + c[k]]
l.sort(reverse=True)
for w in l[:q]:
	print(w)


from heapq import heappop, heappush

def main():

	def push(i, j, k):
		nonlocal A, B, C, ADD
		if i >= x or j >= y or k >= z:
			return
		if (i, j, k) not in ADD:
			heappush(H, (A[i] + B[j] + C[k], i, j, k))
			ADD.add((i, j, k))
	(x, y, z, k) = list(map(int, input().split()))
	INF = 10 ** 11
	A = sorted(list([-int(x) for x in input().split()]))
	B = sorted(list([-int(x) for x in input().split()]))
	C = sorted(list([-int(x) for x in input().split()]))
	H = []
	ADD = set()
	push(0, 0, 0)
	for _ in range(k):
		(ans, i, j, k) = heappop(H)
		push(i + 1, j, k)
		push(i, j + 1, k)
		push(i, j, k + 1)
		print(-ans)

def __starting_point():
	main()
__starting_point()


import sys
import heapq
(X, Y, Z, K) = map(int, sys.stdin.readline().split())
A = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
B = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
C = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
ans_heapq = []
i = 0
j = 0
k = 0
heapq.heappush(ans_heapq, [-1 * (A[0] + B[0] + C[0]), i, j, k])
ijk_list = [[0, 0, 0]]
for _ in range(K):
	(ans, i, j, k) = heapq.heappop(ans_heapq)
	print(-1 * ans)
	if i < X - 1 and [i + 1, j, k] not in ijk_list:
		abc = -1 * (A[i + 1] + B[j] + C[k])
		heapq.heappush(ans_heapq, [abc, i + 1, j, k])
		ijk_list.append([i + 1, j, k])
	if j < Y - 1 and [i, j + 1, k] not in ijk_list:
		abc = -1 * (A[i] + B[j + 1] + C[k])
		heapq.heappush(ans_heapq, [abc, i, j + 1, k])
		ijk_list.append([i, j + 1, k])
	if k < Z - 1 and [i, j, k + 1] not in ijk_list:
		abc = -1 * (A[i] + B[j] + C[k + 1])
		heapq.heappush(ans_heapq, [abc, i, j, k + 1])
		ijk_list.append([i, j, k + 1])


import heapq
from collections import defaultdict
(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]
used = defaultdict(bool)
pq = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
used[0, 0, 0] = True
heapq.heapify(pq)
for _ in range(K):
	(d, i, j, k) = heapq.heappop(pq)
	print(-d)
	if i + 1 < x and (not used[i + 1, j, k]):
		heapq.heappush(pq, (-(a[i + 1] + b[j] + c[k]), i + 1, j, k))
		used[i + 1, j, k] = True
	if j + 1 < y and (not used[i, j + 1, k]):
		heapq.heappush(pq, (-(a[i] + b[j + 1] + c[k]), i, j + 1, k))
		used[i, j + 1, k] = True
	if k + 1 < z and (not used[i, j, k + 1]):
		heapq.heappush(pq, (-(a[i] + b[j] + c[k + 1]), i, j, k + 1))
		used[i, j, k + 1] = True


(x, y, z, k) = map(int, input().split())
aa = sorted(map(int, input().split()))
bb = sorted(map(int, input().split()))
cc = sorted(map(int, input().split()))
ab = sorted((a + b for a in aa for b in bb))[:-k - 1:-1]
abc = sorted((s + c for s in ab[:k] for c in cc))[:-k - 1:-1]
print(*abc, sep='\n')


(X, Y, Z, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = []
ans = []
for a in A:
	for b in B:
		AB.append(a + b)
AB.sort(reverse=True)
AB = AB[:min(3001, X * Y * Z + 1)]
for c in C:
	for ab in AB:
		ans.append(c + ab)
ans.sort(reverse=True)
for i in range(K):
	print(ans[i])


from heapq import *
(X, Y, Z, K) = 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)
cake = []
heapify(cake)
for x in range(X):
	for y in range(min(Y, K // (x + 1) + 1)):
		for k in range(min(Z, K // ((x + 1) * (y + 1)) + 1)):
			heappush(cake, -(A[x] + B[y] + C[k]))
for _ in range(K):
	print(abs(heappop(cake)))


def MAP():
	return list(map(int, input().split()))

def INT():
	return int(input())

def FLOAT():
	return float(input())
MOD = 10 ** 9 + 7
(x, y, z, k) = MAP()
a = MAP()
b = MAP()
c = MAP()
a.sort()
b.sort()
l = []
for i in a:
	for j in b:
		l.append(i + j)
l.sort()
c.sort()
l2 = []
for i in l[-k:]:
	for j in c[-k:]:
		l2.append(i + j)
l2.sort(reverse=True)
for i in l2[:k]:
	print(i)


def main():
	(x, y, z, k) = map(int, input().split())
	lia = sorted(list(map(int, input().split())))
	lib = sorted(list(map(int, input().split())))
	lic = sorted(list(map(int, input().split())))
	li2 = sorted(list((a + b for a in lia for b in lib)), reverse=True)[:k]
	li3 = sorted(list((ab + c for ab in li2 for c in lic)), reverse=True)[:k]
	print('\n'.join(map(str, li3)))
main()


(num_x, num_y, num_z, k) = map(int, input().split())
x_list = sorted(list(map(int, input().split())))
y_list = sorted(list(map(int, input().split())))
z_list = sorted(list(map(int, input().split())))
xy_list = sorted([x + y for x in x_list for y in y_list], reverse=True)[:k]
xyz_list = sorted([xy + z for xy in xy_list for z in z_list], reverse=True)[:k]
for xyz in xyz_list:
	print(xyz)


import heapq
(X, Y, Z, K) = list(map(int, input().split()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
h = []
heapq.heappush(h, (-A[0] - B[0] - C[0], 0, 0, 0))
ans = []
st = set()
for _ in range(K):
	(s, i, j, k) = heapq.heappop(h)
	ans.append(-s)
	if i + 1 < X and (not (i + 1, j, k) in st):
		heapq.heappush(h, (-A[i + 1] - B[j] - C[k], i + 1, j, k))
		st.add((i + 1, j, k))
	if j + 1 < Y and (not (i, j + 1, k) in st):
		heapq.heappush(h, (-A[i] - B[j + 1] - C[k], i, j + 1, k))
		st.add((i, j + 1, k))
	if k + 1 < Z and (not (i, j, k + 1) in st):
		heapq.heappush(h, (-A[i] - B[j] - C[k + 1], i, j, k + 1))
		st.add((i, j, k + 1))
for v in ans:
	print(v)


(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()))
li = []
for i in a:
	for j in b:
		li.append(i + j)
li.sort(reverse=True)
ansli = []
for i in c:
	for j in range(min(k, len(li))):
		ansli.append(i + li[j])
ansli.sort(reverse=True)
for i in range(k):
	print(ansli[i])


import heapq
(x, y, z, k) = map(int, input().split())
alist = sorted(list(map(int, input().split())), reverse=True)
blist = sorted(list(map(int, input().split())), reverse=True)
clist = sorted(list(map(int, input().split())), reverse=True)
l = [(-(alist[0] + blist[0] + clist[0]), 0, 0, 0)]
heapq.heapify(l)
count = 0
ai = bi = ci = 0
selected = set()
selected.add((0, 0, 0))
while len(l) != 0:
	temp = heapq.heappop(l)
	(tempa, tempb, tempc) = temp[1:]
	print(-temp[0])
	count += 1
	if count == k:
		break
	if tempa + 1 <= x - 1:
		if not (tempa + 1, tempb, tempc) in selected:
			heapq.heappush(l, (-(alist[tempa + 1] + blist[tempb] + clist[tempc]), tempa + 1, tempb, tempc))
			selected.add((tempa + 1, tempb, tempc))
	if tempb + 1 <= y - 1:
		if not (tempa, tempb + 1, tempc) in selected:
			heapq.heappush(l, (-(alist[tempa] + blist[tempb + 1] + clist[tempc]), tempa, tempb + 1, tempc))
			selected.add((tempa, tempb + 1, tempc))
	if tempc + 1 <= z - 1:
		if not (tempa, tempb, tempc + 1) in selected:
			heapq.heappush(l, (-(alist[tempa] + blist[tempb] + clist[tempc + 1]), tempa, tempb, tempc + 1))
			selected.add((tempa, tempb, tempc + 1))


import heapq as hq
(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)
abc = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
used = set((0, 0, 0))
while K > 0:
	K -= 1
	(p, i, j, k) = hq.heappop(abc)
	print(-p)
	for (a, b, c) in [(i + 1, j, k), (i, j + 1, k), (i, j, k + 1)]:
		if a < x and b < y and (c < z) and ((a, b, c) not in used):
			used.add((a, b, c))
			hq.heappush(abc, (-(A[a] + B[b] + C[c]), a, b, c))


import heapq
(x, y, z, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
e = []
for va in a:
	for vb in b:
		e.append(va + vb)
e.sort(reverse=True)
e = e[:k]
d = []
for ve in e:
	for vc in c:
		heapq.heappush(d, -(ve + vc))
for i in range(k):
	print(-heapq.heappop(d))


from sys import stdin
import heapq

def main():
	readline = stdin.readline
	(x, y, z, k) = map(int, readline().split())
	a = list(map(int, readline().split()))
	a.sort(reverse=True)
	b = list(map(int, readline().split()))
	b.sort(reverse=True)
	c = list(map(int, readline().split()))
	c.sort(reverse=True)
	s = {(0, 0, 0)}
	h = [[-(a[0] + b[0] + c[0]), (0, 0, 0)]]
	heapq.heapify(h)
	for _ in range(k):
		li = heapq.heappop(h)
		n = -li[0]
		co = li[1]
		print(n)
		if co[0] + 1 < x:
			co_1 = (co[0] + 1, co[1], co[2])
			n_1 = a[co_1[0]] + b[co_1[1]] + c[co_1[2]]
			n_1 = -n_1
			if co_1 not in s:
				heapq.heappush(h, [n_1, co_1])
				s.add(co_1)
		if co[1] + 1 < y:
			co_2 = (co[0], co[1] + 1, co[2])
			n_2 = a[co_2[0]] + b[co_2[1]] + c[co_2[2]]
			n_2 = -n_2
			if co_2 not in s:
				heapq.heappush(h, [n_2, co_2])
				s.add(co_2)
		if co[2] + 1 < z:
			co_3 = (co[0], co[1], co[2] + 1)
			n_3 = a[co_3[0]] + b[co_3[1]] + c[co_3[2]]
			n_3 = -n_3
			if co_3 not in s:
				heapq.heappush(h, [n_3, co_3])
				s.add(co_3)

def __starting_point():
	main()
__starting_point()


from itertools import product
(x, y, z, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sorted([s + t for (s, t) in product(a, b)], reverse=True)[:3000]
e = sorted([s + t for (s, t) in product(c, d)], reverse=True)[:k]
[print(i) for i in e]


def main():
	import heapq
	(x, y, z, k, *abc) = list(map(int, open(0).read().split()))
	a = sorted(abc[:x], reverse=True)
	b = sorted(abc[x:x + y], reverse=True)
	c = sorted(abc[x + y:], reverse=True)
	s = set()
	h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
	heapq.heapify(h)
	num = []
	for _ in range(k):
		(p, i, j, k) = heapq.heappop(h)
		num.append(-p)
		for (p, q, r) in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
			(p, q, r) = (min(i + p, x - 1), min(j + q, y - 1), min(k + r, z - 1))
			if (p, q, r) not in s:
				s.add((p, q, r))
				v = -(a[p] + b[q] + c[r])
				heapq.heappush(h, (v, p, q, r))
	ans = '\n'.join(map(str, num))
	print(ans)

def __starting_point():
	main()
__starting_point()


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(X, Y, Z, K) = map(int, readline().split())
	A = list(map(int, readline().split()))
	B = list(map(int, readline().split()))
	C = list(map(int, readline().split()))
	A.sort(reverse=True)
	B.sort(reverse=True)
	C.sort(reverse=True)
	AB = [a + b for a in A[:K] for b in B[:K]]
	AB.sort(reverse=True)
	ABC = [ab + c for ab in AB[:K] for c in C[:K]]
	ABC.sort(reverse=True)
	print(*ABC[:K], sep='\n')
	return

def __starting_point():
	main()
__starting_point()


import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
sys.setrecursionlimit(10 ** 6)
INF = 10 ** 12
m = 10 ** 9 + 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.sort(reverse=True)
	B.sort(reverse=True)
	C.sort(reverse=True)
	q = []
	heappush(q, (-(A[0] + B[0] + C[0]), 0, 0, 0))
	count = 0
	used = set()
	while count < K:
		(num, s, t, u) = heappop(q)
		print(-num)
		used.add((s, t, u))
		if s + 1 < X and (s + 1, t, u) not in used:
			heappush(q, (-(A[s + 1] + B[t] + C[u]), s + 1, t, u))
			used.add((s + 1, t, u))
		if t + 1 < Y and (s, t + 1, u) not in used:
			heappush(q, (-(A[s] + B[t + 1] + C[u]), s, t + 1, u))
			used.add((s, t + 1, u))
		if u + 1 < Z and (s, t, u + 1) not in used:
			heappush(q, (-(A[s] + B[t] + C[u + 1]), s, t, u + 1))
			used.add((s, t, u + 1))
		count += 1

def __starting_point():
	main()
__starting_point()


import heapq
import sys
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def input():
	return sys.stdin.readline().strip()

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)

	def bfs():
		used = set()
		used.add((0, 0, 0))
		q = []
		heapq.heapify(q)
		heapq.heappush(q, (-(A[0] + B[0] + C[0]), 0, 0, 0))
		res = []
		while q:
			(v, i, j, k) = heapq.heappop(q)
			res.append(-v)
			if len(res) == K:
				return res
			for (di, dj, dk) in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
				ni = i + di
				nj = j + dj
				nk = k + dk
				if ni >= X or nj >= Y or nk >= Z:
					continue
				if (ni, nj, nk) in used:
					continue
				used.add((ni, nj, nk))
				heapq.heappush(q, (-(A[ni] + B[nj] + C[nk]), ni, nj, nk))
		return res
	res = bfs()
	res.sort(reverse=True)
	for i in range(K):
		print(res[i])

def __starting_point():
	main()
__starting_point()


(X, Y, Z, K) = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
B = [int(x) for x in input().split()]
B.sort(reverse=True)
C = [int(x) for x in input().split()]
C.sort(reverse=True)
D = [a + b for a in A for b in B]
D.sort(reverse=True)
D = D[:3000]
E = [ab + c for ab in D for c in C]
E.sort(reverse=True)
for i in range(K):
	print(E[i])


(x, y, z, k) = 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)
sumAB = sorted([ai + bi for ai in a for bi in b], reverse=True)[:k]
sumABC = sorted([ci + abi for ci in c for abi in sumAB], reverse=True)[:k]
for i in range(k):
	print(sumABC[i])


import sys
from heapq import heappush, heappop
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(X, Y, Z, K) = list(map(int, readline().split()))
	A = list(map(int, readline().split()))
	B = list(map(int, readline().split()))
	C = list(map(int, readline().split()))
	A.sort(reverse=True)
	B.sort(reverse=True)
	C.sort(reverse=True)
	hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
	seen = set()
	ans = []
	while len(ans) < K:
		(s, i, j, k) = heappop(hq)
		ans.append(-s)
		if i < X - 1 and (i + 1, j, k) not in seen:
			heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
			seen.add((i + 1, j, k))
		if j < Y - 1 and (i, j + 1, k) not in seen:
			heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
			seen.add((i, j + 1, k))
		if k < Z - 1 and (i, j, k + 1) not in seen:
			heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
			seen.add((i, j, k + 1))
	print('\n'.join(map(str, ans)))
	return

def __starting_point():
	main()
__starting_point()


from itertools import product
import sys
try:
	from typing import List
except ImportError:
	pass

def solve(X: int, Y: int, Z: int, K: int, A: 'List[int]', B: 'List[int]', C: 'List[int]'):
	z = [0]

	def f(a: 'List[int]'):
		nonlocal z
		a.sort(reverse=True)
		z = [zi + ai for (zi, ai) in product(z, a[:K])]
		z.sort(reverse=True)
		z = z[:K]
	f(A)
	f(B)
	f(C)
	for zi in z:
		print(zi)

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	X = int(next(tokens))
	Y = int(next(tokens))
	Z = int(next(tokens))
	K = int(next(tokens))
	A = [int(next(tokens)) for _ in range(X)]
	B = [int(next(tokens)) for _ in range(Y)]
	C = [int(next(tokens)) for _ in range(Z)]
	solve(X, Y, Z, K, A, B, C)

def __starting_point():
	main()
__starting_point()


import itertools
(x, y, z, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = list(sorted(map(sum, itertools.product(a, b)), reverse=True))
c.sort(reverse=True)
e = list(sorted(map(sum, itertools.product(c[:k], d[:k])), reverse=True))
for v in e[:k]:
	print(v)


from heapq import *

def solve():
	(X, Y, Z, K) = 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)
	a = []
	heapify(a)
	ans = []
	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
				heappush(a, -A[i] - B[j] - C[k])
	for _ in range(K):
		ans.append(-heappop(a))
	return ans
print(*solve(), sep='\n')


import sys
readline = sys.stdin.readline
(X, Y, Z, K) = map(int, readline().split())
A = sorted(list(map(int, readline().split())), reverse=True)
B = sorted(list(map(int, readline().split())), reverse=True)
C = sorted(list(map(int, readline().split())), reverse=True)
ans = []
for a in range(len(A)):
	for b in range(len(B)):
		for c in range(len(C)):
			if (a + 1) * (b + 1) * (c + 1) > K:
				break
			ans += [A[a] + B[b] + C[c]]
ans = sorted(ans, reverse=True)[:K]
print(*ans, sep='\n')


from heapq import heappop, heappush
(X, Y, Z, K) = map(int, input().split())
(*A,) = map(int, input().split())
(*B,) = map(int, input().split())
(*C,) = map(int, input().split())
A.sort(reverse=True)
D = [i + j for j in C for i in B]
D.sort(reverse=True)
q = []
for i in A[:K]:
	for j in D[:K]:
		heappush(q, -(i + j))
for _ in range(K):
	print(-heappop(q))


import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10 ** 9))
write = lambda x: sys.stdout.write(x + '\n')
import numpy as np
(x, y, z, K) = list(map(int, input().split()))
a = np.array(list(map(int, input().split())), dtype=np.int64)
b = np.array(list(map(int, input().split())), dtype=np.int64)
c = np.array(list(map(int, input().split())), dtype=np.int64)
ab = (a + b.reshape(-1, 1)).reshape(-1)
ab.sort()
c.sort()
abk = ab[-K:]
ck = c[-K:]
l = (abk + ck.reshape(-1, 1)).reshape(-1)
l.sort()
l = l[::-1]
write('\n'.join(map(str, l[:K])))


import heapq
from collections import defaultdict
(x, y, z, K) = list(map(int, input().split()))
A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)
visited = defaultdict(bool)
Q = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
for _ in range(K):
	(S, i, j, k) = heapq.heappop(Q)
	print(-S)
	if i + 1 < x and (not visited[i + 1, j, k]):
		heapq.heappush(Q, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
		visited[i + 1, j, k] = True
	if j + 1 < y and (not visited[i, j + 1, k]):
		heapq.heappush(Q, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
		visited[i, j + 1, k] = True
	if k + 1 < z and (not visited[i, j, k + 1]):
		heapq.heappush(Q, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
		visited[i, j, k + 1] = True


import heapq
import itertools
(x, y, z, k) = map(int, input().split())
A = list((int(a) for a in input().split()))
B = list((int(b) for b in input().split()))
C = list((int(c) for c in input().split()))
hq = []
for (i, j) in itertools.product(A, B):
	heapq.heappush(hq, (i + j) * -1)
AB = []
while len(hq) > 0 and len(AB) <= k:
	AB.append(heapq.heappop(hq) * -1)
hq = []
for (i, j) in itertools.product(AB, C):
	heapq.heappush(hq, (i + j) * -1)
for _ in range(k):
	print(heapq.heappop(hq) * -1)


import heapq
import itertools
(x, y, z, k) = list(map(int, input().split()))
A = list((int(a) for a in input().split()))
B = list((int(b) for b in input().split()))
C = list((int(c) for c in input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
hq = []
for i in range(x):
	for j in range(y):
		for l in range(z):
			if (i + 1) * (j + 1) * (l + 1) <= k:
				heapq.heappush(hq, (A[i] + B[j] + C[l]) * -1)
			else:
				break
for _ in range(k):
	print(heapq.heappop(hq) * -1)


(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 = [A[i] + B[j] for i in range(X) for j in range(Y)]
AB = sorted(AB, reverse=True)[:K]
ABC = [AB[i] + C[j] for i in range(len(AB)) for j in range(Z)]
ABC = sorted(ABC, reverse=True)[:K]
for one in ABC:
	print(one)


from heapq import heapify, heappop, heappush, heappushpop

class PriorityQueue:

	def __init__(self, heap):
		self.heap = heap
		heapify(self.heap)

	def push(self, item):
		heappush(self.heap, item)

	def pop(self):
		return heappop(self.heap)

	def pushpop(self, item):
		return heappushpop(self.heap, item)

	def __call__(self):
		return self.heap

	def __len__(self):
		return len(self.heap)
(x, y, z, k) = list(map(int, input().split()))
a_ls = list(map(int, input().split()))
b_ls = list(map(int, input().split()))
c_ls = list(map(int, input().split()))
a_ls.sort()
a_ls.reverse()
b_ls.sort()
b_ls.reverse()
c_ls.sort()
c_ls.reverse()
heap = []
q = PriorityQueue(heap)
q.push((-(a_ls[0] + b_ls[0] + c_ls[0]), 0, 0, 0))
considered = set()
for i in range(k):
	(val, i, j, k) = q.pop()
	print(-val)
	for (di, dj, dk) in zip([1, 0, 0], [0, 1, 0], [0, 0, 1]):
		ni = i + di
		nj = j + dj
		nk = k + dk
		if ni >= x or nj >= y or nk >= z:
			continue
		if (ni, nj, nk) not in considered:
			considered.add((ni, nj, nk))
			q.push((-(a_ls[ni] + b_ls[nj] + c_ls[nk]), ni, nj, nk))


import sys
input = sys.stdin.readline
import heapq
from collections import defaultdict

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

def solve(X, Y, Z, K, A, B, C, INF=10000000001):
	A.sort(reverse=True)
	B.sort(reverse=True)
	C.sort(reverse=True)
	used = defaultdict(bool)
	h = []
	(p, q, r) = (0, 0, 0)
	heapq.heappush(h, (-A[p] - B[q] - C[r], p, q, r))
	used[p, q, r] = True
	for k in range(K):
		(a, p, q, r) = heapq.heappop(h)
		print(-a)
		if p + 1 < len(A) and (not used[p + 1, q, r]):
			heapq.heappush(h, (-A[p + 1] - B[q] - C[r], p + 1, q, r))
			used[p + 1, q, r] = True
		if q + 1 < len(B) and (not used[p, q + 1, r]):
			heapq.heappush(h, (-A[p] - B[q + 1] - C[r], p, q + 1, r))
			used[p, q + 1, r] = True
		if r + 1 < len(C) and (not used[p, q, r + 1]):
			heapq.heappush(h, (-A[p] - B[q] - C[r + 1], p, q, r + 1))
			used[p, q, r + 1] = True

def __starting_point():
	inputs = read()
	solve(*inputs)
__starting_point()


import heapq
(x, y, z, k) = 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)
q = []
s = set()
heapq.heappush(q, (-a[0] - b[0] - c[0], 0, 0, 0))
for i in range(k):
	(ans, ai, bi, ci) = heapq.heappop(q)
	print(-ans)
	if ai < x - 1 and (ai + 1, bi, ci) not in s:
		heapq.heappush(q, (-a[ai + 1] - b[bi] - c[ci], ai + 1, bi, ci))
		s.add((ai + 1, bi, ci))
	if bi < y - 1 and (ai, bi + 1, ci) not in s:
		heapq.heappush(q, (-a[ai] - b[bi + 1] - c[ci], ai, bi + 1, ci))
		s.add((ai, bi + 1, ci))
	if ci < z - 1 and (ai, bi, ci + 1) not in s:
		heapq.heappush(q, (-a[ai] - b[bi] - c[ci + 1], ai, bi, ci + 1))
		s.add((ai, bi, ci + 1))


(X, Y, Z, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for a in A for b in B]
AB.sort()
AB = AB[-K:]
ans = [ab + c for ab in AB for c in C]
ans.sort()
for x in ans[-K:][::-1]:
	print(x)


(X, Y, Z, K) = list(map(int, input().split()))
A = [sorted(list(map(int, input().split())))[::-1] for i in range(3)]
b = sorted([i + j for i in A[0] for j in A[1]])[-K:]
for i in sorted([i + j for i in b for j in A[2]])[-K:][::-1]:
	print(i)


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

def func1():
	E = [a + b for a in A for b in B]
	E.sort()
	if len(E) > k:
		E = E[-k:]
	F = [c + e for c in C for e in E]
	F.sort()
	return F[-k:][::-1]
[print(val) for val in func1()]


(x, y, z, k) = 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)
bc = [x + y for y in c for x in b]
bc.sort(reverse=True)
ans = [x + y for y in a for x in bc[:k]]
ans.sort(reverse=True)
print(*ans[:k], sep='\n')


import heapq
(X, Y, Z, K) = map(int, input().split())
A = list(map(lambda x: -1 * int(x), input().split()))
B = list(map(lambda x: -1 * int(x), input().split()))
C = list(map(lambda x: -1 * int(x), input().split()))
A.sort()
B.sort()
C.sort()
Q = []
heapq.heappush(Q, (A[0] + B[0] + C[0], 0, 0, 0))
for _ in range(K):
	(SUM, a, b, c) = heapq.heappop(Q)
	print(-1 * SUM)
	if a <= X - 2 and (not (A[a + 1] + B[b] + C[c], a + 1, b, c) in Q):
		heapq.heappush(Q, (A[a + 1] + B[b] + C[c], a + 1, b, c))
	if b <= Y - 2 and (not (A[a] + B[b + 1] + C[c], a, b + 1, c) in Q):
		heapq.heappush(Q, (A[a] + B[b + 1] + C[c], a, b + 1, c))
	if c <= Z - 2 and (not (A[a] + B[b] + C[c + 1], a, b, c + 1) in Q):
		heapq.heappush(Q, (A[a] + B[b] + C[c + 1], a, b, c + 1))


(x, y, z, k) = map(int, input().split())
(a, b, c) = [list(map(int, input().split())) for i in range(3)]
l = sorted([bb + cc for bb in b for cc in c], reverse=1)[:k]
t = sorted([ll + aa for aa in a for ll in l], reverse=1)
for i in range(k):
	print(t[i])