#!/usr/bin/python

import sys

import heapq

R=lambda:list(map(int,sys.stdin.readline().split()))

xa,xb,xc,k=R()

a=sorted(R())

b=sorted(R())

c=sorted(R())

h=set()

q=[[-(a[-1]+b[-1]+c[-1]),xa-1,xb-1,xc-1]]

for _ in range(k):

	x,ya,yb,yc=heapq.heappop(q)

	print((-x))

	if ya>0 and (ya-1,yb,yc) not in h:

		h.add((ya-1,yb,yc))

		heapq.heappush(q,[x+a[ya]-a[ya-1],ya-1,yb,yc])

	if yb>0 and (ya,yb-1,yc) not in h:

		h.add((ya,yb-1,yc))

		heapq.heappush(q,[x+b[yb]-b[yb-1],ya,yb-1,yc])

	if yc>0 and (ya,yb,yc-1) not in h:

		h.add((ya,yb,yc-1))

		heapq.heappush(q,[x+c[yc]-c[yc-1],ya,yb,yc-1])
import sys,heapq

R=lambda:list(map(int,sys.stdin.readline().split()))

x=list(R())

k=x.pop()

a=[sorted(R())for _ in range(3)]

h=set()

q=[[-sum(e[-1] for e in a)]+[e-1 for e in x]]

for _ in range(k):

	y=heapq.heappop(q)

	x=y.pop(0)

	print((-x))

	for i in range(3):

		ny=list(y)

		ny[i]-=1

		if y[i] and tuple(ny) not in h:

			h.add(tuple(ny))

			heapq.heappush(q,[x+a[i][y[i]]-a[i][y[i]-1]]+ny)
#!/usr/bin/python
import sys
import heapq

R = lambda: list(map(int, sys.stdin.readline().split()))
xa, xb, xc, k = R()
a = sorted(R())
b = sorted(R())
c = sorted(R())
h = set()
q = [[-(a[-1] + b[-1] + c[-1]), xa - 1, xb - 1, xc - 1]]
for _ in range(k):
    x, ya, yb, yc = heapq.heappop(q)
    print((-x))
    if ya > 0 and (ya - 1, yb, yc) not in h:
        h.add((ya - 1, yb, yc))
        heapq.heappush(q, [x + a[ya] - a[ya - 1], ya - 1, yb, yc])
    if yb > 0 and (ya, yb - 1, yc) not in h:
        h.add((ya, yb - 1, yc))
        heapq.heappush(q, [x + b[yb] - b[yb - 1], ya, yb - 1, yc])
    if yc > 0 and (ya, yb, yc - 1) not in h:
        h.add((ya, yb, yc - 1))
        heapq.heappush(q, [x + c[yc] - c[yc - 1], ya, yb, yc - 1])

import sys, heapq

R = lambda: list(map(int, sys.stdin.readline().split()))
x = list(R())
k = x.pop()
a = [sorted(R()) for _ in range(3)]
h = set()
q = [[-sum(e[-1] for e in a)] + [e - 1 for e in x]]
for _ in range(k):
    y = heapq.heappop(q)
    x = y.pop(0)
    print((-x))
    for i in range(3):
        ny = list(y)
        ny[i] -= 1
        if y[i] and tuple(ny) not in h:
            h.add(tuple(ny))
            heapq.heappush(q, [x + a[i][y[i]] - a[i][y[i] - 1]] + ny)

-#!/usr/bin/python -import sys -import heapq +import sys, heapq -xa, xb, xc, k = R() -a = sorted(R()) -b = sorted(R()) -c = sorted(R()) +x = list(R()) +k = x.pop() +a = [sorted(R()) for _ in range(3)] -q = [[-(a[-1] + b[-1] + c[-1]), xa - 1, xb - 1, xc - 1]] +q = [[-sum(e[-1] for e in a)] + [e - 1 for e in x]] -    x, ya, yb, yc = heapq.heappop(q) +    y = heapq.heappop(q) +    x = y.pop(0) -    if ya > 0 and (ya - 1, yb, yc) not in h: -        h.add((ya - 1, yb, yc)) -        heapq.heappush(q, [x + a[ya] - a[ya - 1], ya - 1, yb, yc]) -    if yb > 0 and (ya, yb - 1, yc) not in h: -        h.add((ya, yb - 1, yc)) -        heapq.heappush(q, [x + b[yb] - b[yb - 1], ya, yb - 1, yc]) -    if yc > 0 and (ya, yb, yc - 1) not in h: -        h.add((ya, yb, yc - 1)) -        heapq.heappush(q, [x + c[yc] - c[yc - 1], ya, yb, yc - 1]) +    for i in range(3): +        ny = list(y) +        ny[i] -= 1 +        if y[i] and tuple(ny) not in h: +            h.add(tuple(ny)) +            heapq.heappush(q, [x + a[i][y[i]] - a[i][y[i] - 1]] + ny)