CodeEff/ECCO huggingface dataset:
# Original solution
a, b, c, d = list(map(int, input().split()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al = sorted(al, reverse=True)
bl = sorted(bl, reverse=True)
cl = sorted(cl, reverse=True)
q = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
ans = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
c = -1
#while True:
    #c += 1
for i in range(d):
    #print(c)
    #print(len(ans))
    s, aq, bq, cq = list(map(int, q.pop()))
    if len(al) > aq+1:
        if [al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq] not in ans:
            q.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])
            ans.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])

    if len(bl) > bq+1:
        if [al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq] not in ans:
            q.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])
            ans.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])

    if len(cl) > cq+1:
        if [al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1] not in ans:
            q.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])
            ans.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])

    q = sorted(q)

    if len(ans) > d:
        ans = sorted(ans, reverse=True)
        if ans[d-1][0] > q[len(q)-1][0]:
            break

ans = sorted(ans, reverse=True)
for i in range(d):
    print((ans[i][0]))


# Optimized solution
a, b, c, d = list(map(int, input().split()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al = sorted(al, reverse=True)
bl = sorted(bl, reverse=True)
cl = sorted(cl, reverse=True)
q = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
ans = [[al[0] + bl[0] + cl[0], 0, 0, 0]]
c = -1
#while True:
    #c += 1
for i in range(d):
    #print(c)
    #print(len(ans))
    s, aq, bq, cq = list(map(int, q.pop()))
    if len(al) > aq+1:
        if [al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq] not in ans:
            q.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])
            ans.append([al[aq+1] + bl[bq] + cl[cq], aq+1, bq, cq])

    if len(bl) > bq+1:
        if [al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq] not in ans:
            q.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])
            ans.append([al[aq] + bl[bq+1] + cl[cq], aq, bq+1, cq])

    if len(cl) > cq+1:
        if [al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1] not in ans:
            q.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])
            ans.append([al[aq] + bl[bq] + cl[cq+1], aq, bq, cq+1])

    q = sorted(q)

    #if len(ans) > d:
    #    ans = sorted(ans, reverse=True)
    #    if ans[d-1][0] > q[len(q)-1][0]:
    #       break

ans = sorted(ans, reverse=True)
for i in range(d):
    print((ans[i][0]))
# Original solution
X, Y, Z, K = list(map(int, input().split()))

list_cake_1 = list(map(int, input().split()))
list_cake_2 = list(map(int, input().split()))
list_cake_3 = list(map(int, input().split()))

list_cake_1 = sorted(list_cake_1, reverse=True)
list_cake_2 = sorted(list_cake_2, reverse=True)
list_cake_3 = sorted(list_cake_3, reverse=True)


list_total_sum = [cake_1 + cake_2 + cake_3 for i, cake_1 in enumerate(list_cake_1, 1) for j, cake_2 in enumerate(list_cake_2, 1) for k, cake_3 in enumerate(list_cake_3, 1) if i*j*k <= K]

for element in sorted(list_total_sum, reverse=True)[:K]:
	print(element)

# Optimized solution
import sys

input = sys.stdin.readline

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

list_cake_1 = list(map(int, input().split()))
list_cake_2 = list(map(int, input().split()))
list_cake_3 = list(map(int, input().split()))

list_cake_1 = sorted(list_cake_1, reverse=True)
list_cake_2 = sorted(list_cake_2, reverse=True)
list_cake_3 = sorted(list_cake_3, reverse=True)

list_total_sum = []

for i, cake_1 in enumerate(list_cake_1, 1):
	for j, cake_2 in enumerate(list_cake_2, 1):
		for k, cake_3 in enumerate(list_cake_3, 1):
			if i*j*k > K:
				break
			list_total_sum.append(cake_1 + cake_2 + cake_3)

for element in sorted(list_total_sum, reverse=True)[:K]:
	print(element)
# Original solution
import heapq
X,Y,Z,K = list(map(int,input().split()))
A = sorted(list(map(int,input().split())),reverse=1)
B = sorted(list(map(int,input().split())),reverse=1)
C = sorted(list(map(int,input().split())),reverse=1)
Q = [(-A[0]-B[0]-C[0],0,0,0)]
heapq.heapify(Q)
abc = [[[1 for i in range(Z)] for j in range(Y)] for k in range(X)]
for i in range(K):
    n,a,b,c = heapq.heappop(Q)
    if a < X-1 and abc[a+1][b][c]:
        abc[a+1][b][c] = 0
        heapq.heappush(Q,(n+A[a]-A[a+1],a+1,b,c))
    if b < Y-1 and abc[a][b+1][c]:
        abc[a][b+1][c] = 0
        heapq.heappush(Q,(n+B[b]-B[b+1],a,b+1,c))
    if c < Z-1 and abc[a][b][c+1]:
        abc[a][b][c+1] = 0
        heapq.heappush(Q,(n+C[c]-C[c+1],a,b,c+1))
    print((-n))

# Optimized solution
import heapq
X,Y,Z,K = list(map(int,input().split()))
A = sorted(list(map(int,input().split())),reverse=1)
B = sorted(list(map(int,input().split())),reverse=1)
C = sorted(list(map(int,input().split())),reverse=1)
Q = [(-A[0]-B[0]-C[0],0,0,0)]
heapq.heapify(Q)
abc = [(0,0,0)]
for i in range(K):
    n,a,b,c = heapq.heappop(Q)
    if a < X-1 and (a+1,b,c) not in abc:
        abc.append((a+1,b,c))
        heapq.heappush(Q,(n+A[a]-A[a+1],a+1,b,c))
    if b < Y-1 and (a,b+1,c) not in abc:
        abc.append((a,b+1,c))
        heapq.heappush(Q,(n+B[b]-B[b+1],a,b+1,c))
    if c < Z-1 and (a,b,c+1) not in abc:
        abc.append((a,b,c+1))
        heapq.heappush(Q,(n+C[c]-C[c+1],a,b,c+1))
    print((-n))
# Original solution
from heapq import heappop, heappush

X, Y, Z, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
h = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            heappush(h, -(A[i] + B[j] + C[k]))
for _ in range(K):
    print((-heappop(h)))


# Optimized solution
from heapq import heappop, heappush

X, Y, Z, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
counted = set()
h = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
for _ in range(K):
    s, i, j, k = heappop(h)
    print((-s))
    if X > i+1 and (i+1, j, k) not in counted:
        heappush(h, (-(A[i+1] + B[j] + C[k]), i+1, j, k))
        counted.add((i+1, j, k))
    if Y > j+1 and (i, j+1, k) not in counted:
        heappush(h, (-(A[i] + B[j+1] + C[k]), i, j+1, k))
        counted.add((i, j+1, k))
    if Z > k+1 and (i, j, k+1) not in counted:
        heappush(h, (-(A[i] + B[j] + C[k+1]), i, j, k+1))
        counted.add((i, j, k+1))
# Original solution
import heapq as hq
x, y, z, k = list(map(int,input().split()))
arr_a = sorted(list(map(int,input().split())) ,reverse = True)
arr_b = sorted(list(map(int,input().split())) ,reverse = True)
arr_c = sorted(list(map(int,input().split())) ,reverse = True)

cnt = [[[0 for i in range(z)] for j in range(y)] for k in range(x)]
P_q = [[-(arr_a[0] + arr_b[0] + arr_c[0]),0,0,0]]

cnt[0][0][0] = 1
for _ in range(k):
    tmp = hq.heappop(P_q)
    t, i, j, k = -tmp[0],tmp[1],tmp[2],tmp[3]
    print(t)
    if i + 1 < x and cnt[i+1][j][k] == 0:
        hq.heappush(P_q,[-(arr_a[i+1] + arr_b[j] + arr_c[k]) ,i + 1,j,k])
        cnt[i+1][j][k] = 1
    if j + 1 < y and cnt[i][j + 1][k] == 0:
        hq.heappush(P_q,[-(arr_a[i] + arr_b[j+1] + arr_c[k]) ,i ,j + 1,k])
        cnt[i][j+1][k] = 1
    if k + 1 < z and cnt[i][j][k + 1] == 0:
        hq.heappush(P_q,[-(arr_a[i] + arr_b[j] + arr_c[k + 1]) ,i,j,k + 1])
        cnt[i][j][k + 1] = 1
        

# Optimized solution
import heapq as hq
x, y, z, k = list(map(int,input().split()))
arr_a = sorted(list(map(int,input().split())) ,reverse = True)
arr_b = sorted(list(map(int,input().split())) ,reverse = True)
arr_c = sorted(list(map(int,input().split())) ,reverse = True)

cnt = set()
P_q = [[-(arr_a[0] + arr_b[0] + arr_c[0]),0,0,0]]

cnt.add((0,0,0))
for _ in range(k):
    tmp = hq.heappop(P_q)
    t, i, j, k = -tmp[0],tmp[1],tmp[2],tmp[3]
    print(t)
    if i + 1 < x and (i+1,j,k) not in cnt:
        hq.heappush(P_q,[-(arr_a[i+1] + arr_b[j] + arr_c[k]) ,i + 1,j,k])
        cnt.add((i+1,j,k))
    if j + 1 < y and (i,j+1,k) not in cnt:
        hq.heappush(P_q,[-(arr_a[i] + arr_b[j+1] + arr_c[k]) ,i ,j + 1,k])
        cnt.add((i,j+1,k))
    if k + 1 < z and (i,j,k+1) not in cnt:
        hq.heappush(P_q,[-(arr_a[i] + arr_b[j] + arr_c[k + 1]) ,i,j,k + 1])
        cnt.add((i,j,k+1))
# Original solution
import heapq as hq

x,y,z,k = list(map(int,input().split()))
a = list([int(x) * (-1) for x in input().split()])
b =list([int(x) * (-1) for x in input().split()])
c = list([int(x) * (-1) for x in input().split()])
a.sort()
b.sort()
c.sort()
possibles = [(a[0]+b[0]+c[0],0,0,0)]

done = [[[0 for _ in range(z)]for _ in range(y)] for _ in range(x)]
done[0][0][0] = 1
def neibor(ai,bi,ci,possibles,done):
    for aj,bj,cj in [(ai+1,bi,ci),(ai,bi+1,ci),(ai,bi,ci+1)]:
        if (aj<=x-1) and (bj<=y-1) and (cj<=z-1) and (not done[aj][bj][cj]):
            hq.heappush(possibles,(a[aj]+b[bj]+c[cj],aj,bj,cj))
            done[aj][bj][cj] = 1
    

def conf(possibles,done):
    yam,ai,bi,ci = hq.heappop(possibles)
    print((-1*yam))
    neibor(ai,bi,ci,possibles,done)

for i in range(k):
    yam,ai,bi,ci = hq.heappop(possibles)
    print((-1*yam))
    for aj,bj,cj in [(ai+1,bi,ci),(ai,bi+1,ci),(ai,bi,ci+1)]:
        if (aj<=x-1) and (bj<=y-1) and (cj<=z-1) and (not done[aj][bj][cj]):
            hq.heappush(possibles,(a[aj]+b[bj]+c[cj],aj,bj,cj))
            done[aj][bj][cj] = 1

# Optimized solution
import heapq as hq

x,y,z,k = list(map(int,input().split()))
a = list([int(x) * (-1) for x in input().split()])
b =list([int(x) * (-1) for x in input().split()])
c = list([int(x) * (-1) for x in input().split()])
a.sort()
b.sort()
c.sort()
possibles = [(a[0]+b[0]+c[0],0,0,0)]

done = set()
done |= {(0,0,0)}
def neibor(ai,bi,ci,possibles,done):
    for aj,bj,cj in [(ai+1,bi,ci),(ai,bi+1,ci),(ai,bi,ci+1)]:
        if (aj<=x-1) and (bj<=y-1) and (cj<=z-1) and (not (aj,bj,cj) in done):
            hq.heappush(possibles,(a[aj]+b[bj]+c[cj],aj,bj,cj))
            done  |= {(aj,bj,cj)}
    

def conf(possibles,done):
    yam,ai,bi,ci = hq.heappop(possibles)
    print((-1*yam))
    neibor(ai,bi,ci,possibles,done)

for i in range(k):
    yam,ai,bi,ci = hq.heappop(possibles)
    print((-1*yam))
    for aj,bj,cj in [(ai+1,bi,ci),(ai,bi+1,ci),(ai,bi,ci+1)]:
        if (aj<=x-1) and (bj<=y-1) and (cj<=z-1) and (not (aj,bj,cj) in done):
            hq.heappush(possibles,(a[aj]+b[bj]+c[cj],aj,bj,cj))
            done  |= {(aj,bj,cj)}
# Original solution
from heapq import heappush, nlargest

def main():
    X, Y, Z, K = list(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()]
    h = []
    for i in A:
        for j in B:
            for k in C:
                heappush(h, i + j + k)
    for i in nlargest(K, h):
        print(i)


if __name__ == "__main__":
    main()

# Optimized solution
from heapq import heappush, nlargest

def main():
    X, Y, Z, K = list(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()]
    h = []
    for i in A:
        for j in B:
            heappush(h, i + j)
    H = []
    for i in nlargest(K, h):
        for j in C:
            heappush(H, i+j)
    for i in nlargest(K, H):
        print(i)

if __name__ == "__main__":
    main()
# Original solution
from operator import itemgetter

K = int(input().split()[-1])

A = sorted([int(e) for e in input().split()], reverse=True)
B = sorted([int(e) for e in input().split()], reverse=True)
C = sorted([int(e) for e in input().split()], reverse=True)


def get_next_iter(i, _list):
    if i < len(_list) - 1:
        return i + 1
    else:
        return i


values = []

ia = ib = ic = 0


def get_value(ia, ib, ic):
    return A[ia] + B[ib] + C[ic]


def get_next(ia, ib, ic):
    ia_n = get_next_iter(ia, A)
    ib_n = get_next_iter(ib, B)
    ic_n = get_next_iter(ic, C)
    s = set()
    s.add((ia_n, ib, ic, get_value(ia_n, ib, ic)))
    s.add((ia, ib_n, ic, get_value(ia, ib_n, ic)))
    s.add((ia, ib, ic_n, get_value(ia, ib, ic_n)))
    return s


values.append((ia, ib, ic, get_value(ia, ib, ic)))
candidate = get_next(0, 0, 0)

for k in range(K - 1):
    vs = sorted(candidate, reverse=True, key=itemgetter(3))
    for i, v in enumerate(vs):
        if v not in values:
            values.append(v)
            candidate.remove(v)
            for each in get_next(v[0], v[1], v[2]):
                candidate.add(each)
            break
        else:
            continue

for each in values:
    print((each[3]))


# Optimized solution
from heapq import heappush, heappop

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

A = sorted([int(e) for e in input().split()], reverse=True)
B = sorted([int(e) for e in input().split()], reverse=True)
C = sorted([int(e) for e in input().split()], reverse=True)


def get_value(ai, bi, ci):
    return -(A[ai] + B[bi] + C[ci])


heap = []
heappush(heap, (get_value(0, 0, 0), 0, 0, 0))
used = {(0, 0, 0)}

for k in range(K):
    v, ia, ib, ic = heappop(heap)
    print((-v))

    if ia + 1 < X and (ia + 1, ib, ic) not in used:
        heappush(heap, (get_value(ia + 1, ib, ic), ia + 1, ib, ic))
        used.add((ia + 1, ib, ic))
    if ib + 1 < Y and (ia, ib + 1, ic) not in used:
        heappush(heap, (get_value(ia, ib + 1, ic), ia, ib + 1, ic))
        used.add((ia, ib + 1, ic))
    if ic + 1 < Z and (ia, ib, ic + 1) not in used:
        heappush(heap, (get_value(ia, ib, ic + 1), ia, ib, ic + 1))
        used.add((ia, ib, ic + 1))
# Original solution
import heapq
import itertools
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()))
l = list(itertools.product(a, b, c))
m = list([sum(x) for x in l])
m2 = heapq.nlargest(k, m)
for i in range(k):
  print((m2[i]))


# Optimized solution
import heapq
import itertools

def dif(l):
  return max(l) - min(l)

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)

while x*y*z > k and dif(a) > dif(b) and dif(a) > dif(c):
  a.pop()
  x -= 1

while x*y*z > k and dif(b) > dif(a) and dif(b) > dif(c):
  b.pop()
  y -= 1

while x*y*z > k and dif(c) > dif(b) and dif(c) > dif(a):
  c.pop()
  z -= 1

l=[]
for a1 in a:
    for b1 in b:
        for c1 in c:
            l.append(a1+b1+c1)

m2 = heapq.nlargest(k, l)
for i in range(k):
  print((m2[i]))
# Original solution
from heapq import heapify, heappop, heappush
from collections import defaultdict

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 = list(sorted(a, reverse=True))
b = list(sorted(b, reverse=True))
c = list(sorted(c, reverse=True))

t = a[0] + b[0] + c[0]
t *= -1
d = defaultdict(list)
d[t] = [(0, 0, 0)]

q = list()
heapify(q)
heappush(q, t)

a_j = (1, 0, 0)
b_j = (0, 1, 0)
c_j = (0, 0, 1)

st = set()
for i in range(K):
    t = heappop(q)
    print((-t))
    for v in d[t]:
        a_i, b_i, c_i = v
        for j in range(3):
            na_i = a_i + a_j[j]
            if na_i >= X: continue
            nb_i = b_i + b_j[j]
            if nb_i >= Y: continue
            nc_i = c_i + c_j[j]
            if nc_i >= Z: continue

            nt = a[na_i] + b[nb_i] + c[nc_i]
            nt *= -1
            nv = (na_i, nb_i, nc_i)

            # print(nt, nv)

            if nv in st: continue
            d[nt].append(nv)
            st.add(nv)
            heappush(q, nt)


# Optimized solution
# https://www.kumilog.net/entry/python-speed-comp#input-%E3%81%A8-sysstdinreadline
# https://teratail.com/questions/88396

from heapq import heapify, heappush, heappop
import sys

input = sys.stdin.readline


class Data:
    def __init__(self, value, indices):
        self.value = value
        self.indices = indices

    def __lt__(self, other):
        return self.value < other.value


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 = list(sorted(a, reverse=True))
b = list(sorted(b, reverse=True))
c = list(sorted(c, reverse=True))

hq = []
heapify(hq)

t = a[0] + b[0] + c[0]
t *= -1

d = Data(t, (0, 0, 0))

heappush(hq, d)

dtpls = ((1, 0, 0), (0, 1, 0), (0, 0, 1))

st = set()

cnt = 0
for _ in range(K):
    d = heappop(hq)
    print((-d.value))
    for dtpl in dtpls:
        na = d.indices[0] + dtpl[0]
        if na >= X: continue
        nb = d.indices[1] + dtpl[1]
        if nb >= Y: continue
        nc = d.indices[2] + dtpl[2]
        if nc >= Z: continue

        nt = a[na] + b[nb] + c[nc]
        nt *= - 1

        ntpl = (na, nb, nc)
        if ntpl in st: continue
        heappush(hq, Data(nt, ntpl))
        st.add(ntpl)
# Original solution
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)

d = [aa + bb for aa in a[:k] for bb in b[:k]]
d.sort(reverse=True)

e = [dd + cc for dd in d[:k] for cc in c[:k]]
e.sort(reverse=True)

print(*e[:k], sep='\n')


# Optimized solution
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)

d = []
for ai, aa in enumerate(a, 1):
    for bi, bb in enumerate(b, 1):
        for ci, cc in enumerate(c, 1):
            if ai * bi * ci > k:
                break
                # (ai,bi,ci)より合計の大きい選び方がk通り以上存在する
                # (ai,bi)を含む組み合わせは、これ以上調べる必要がない
            d.append(aa + bb + cc)

d.sort(reverse=True)

print(*d[:k], sep='\n')
# Original solution
def main():
    import sys

    input = sys.stdin.readline

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

    ret = sorted(
        (a + b + c
         for p, a in enumerate(A)
         for q, b in enumerate(B)
         for r, c in enumerate(C)
         if p * q * r <= k
         ), reverse=True)[:k]

    print(*ret, sep='\n')


main()

# O(Klog^3K)
# https://img.atcoder.jp/abc123/editorial.pdf


# Optimized solution
def main():
    import sys

    input = sys.stdin.readline

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

    ret = []
    for p, a in enumerate(A):
        for q, b in enumerate(B):
            if p * q > k:
                break
            for r, c in enumerate(C):
                if p * q * r > k:
                    break
                ret.append(a + b + c)
    ret.sort(reverse=True)
    print(*ret[:k], sep='\n')


main()

# O(Klog^3K)
# https://img.atcoder.jp/abc123/editorial.pdf
# Original solution
def main():
    import sys

    input = sys.stdin.readline

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

    ret = []
    for p, a in enumerate(A):
        for q, b in enumerate(B):
            if p * q > k:
                break
            for r, c in enumerate(C):
                if p * q * r > k:
                    break
                ret.append(a + b + c)
    ret.sort(reverse=True)
    print(*ret[:k], sep='\n')


main()

# O(Klog^3K)
# https://img.atcoder.jp/abc123/editorial.pdf


# Optimized solution
def main():
    import sys

    input = sys.stdin.readline

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

    ret = []
    for p, a in enumerate(A, 1):
        for q, b in enumerate(B, 1):
            if p * q > k:
                break
            for r, c in enumerate(C, 1):
                if p * q * r > k:
                    break
                ret.append(a + b + c)
    ret.sort(reverse=True)
    print(*ret[:k], sep='\n')


main()

# O(Klog^3K)
# https://img.atcoder.jp/abc123/editorial.pdf
# Enumerateのindex間違えていた
# Original solution
x,y,z,k=[int(i) for i in 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()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()

a2=a[:k]
b2=[]
for i in a2:
  for j in b[:k]:
    b2.append(i+j)
  b2.sort()
  b2.reverse()
  b2=b2[:k]

c2=[]
for i in b2:
  for j in c[:k]:
    c2.append(i+j)
  c2.sort()
  c2.reverse()
  c2=c2[:k]
for i in c2:
  print(i)

# Optimized solution
xx, yy, zz, k = [int(i) for i in 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(reverse=1)
b.sort(reverse=1)
c.sort(reverse=1)
ans = []

for x in range(min(xx, k)):
    for y in range(min(yy, k // (x + 1))):
        for z in range(min(zz, k // ((x + 1) * (y + 1)))):
            ans.append(a[x] + b[y] + c[z])
ans.sort(reverse=1)

for i in range(k):
    print((ans[i]))
# Original solution
import itertools
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)
del a[min(k,x):]
del b[min(k,y):]
del c[min(k,z):]
 
ab = [i + j for (i, j) in list(itertools.product(a, b))]
 
ab.sort(reverse=True)
del ab[min(k,x*y):]
 
abc = [ij + h for (ij, h) in list(itertools.product(ab, c))]
 
abc.sort(reverse=True)
 
for g in range(k):
  print((abc[g]))

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

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]))
# 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, C)
    data = [i + j + k for i, j, k in p]
    data.sort(reverse=True)

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

if __name__ == '__main__':
    main()


# Optimized 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()