CodeEff/ECCO huggingface dataset:
# 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()))

def diff(l):
    m = max(l)
    return sorted(m - v for v in l)[1:]

s = sum(map(max, [a, b, c]))
sa, sb, sc = list(map(diff, [a, b, c]))
da, db, dc = [0], [0], [0]
q = [0]
while k > 0:
    while True:
        if len(sa) > 0 and (len(q) == 0 or q[0] >= sa[0]):
            for v in [sa[0] + bb + cc for bb in db for cc in dc]:
                heapq.heappush(q, v)
            da.append(sa[0])
            sa = sa[1:]
        elif len(sb) > 0 and (len(q) == 0 or q[0] >= sb[0]):
            for v in [sb[0] + aa + cc for aa in da for cc in dc]:
                heapq.heappush(q, v)
            db.append(sb[0])
            sb = sb[1:]
        elif len(sc) > 0 and (len(q) == 0 or q[0] >= sc[0]):
            for v in [sc[0] + aa + bb for aa in da for bb in db]:
                heapq.heappush(q, v)
            dc.append(sc[0])
            sc = sc[1:]
        else:
            break
    v = heapq.heappop(q)
    print(s - v)
    k -= 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()))

def diff(l):
    m = max(l)
    return sorted(m - v for v in l)[1:]

s = sum(map(max, [a, b, c]))
sa, sb, sc = list(map(diff, [a, b, c]))
da, db, dc = [0], [0], [0]
q = [0]
while k > 0:
    while True:
        if len(sa) > 0 and (len(q) == 0 or q[0] > sa[0]):
            for v in [sa[0] + bb + cc for bb in db for cc in dc]:
                heapq.heappush(q, v)
            da.append(sa[0])
            sa = sa[1:]
        elif len(sb) > 0 and (len(q) == 0 or q[0] > sb[0]):
            for v in [sb[0] + aa + cc for aa in da for cc in dc]:
                heapq.heappush(q, v)
            db.append(sb[0])
            sb = sb[1:]
        elif len(sc) > 0 and (len(q) == 0 or q[0] > sc[0]):
            for v in [sc[0] + aa + bb for aa in da for bb in db]:
                heapq.heappush(q, v)
            dc.append(sc[0])
            sc = sc[1:]
        else:
            break
    v = heapq.heappop(q)
    print(s - v)
    k -= 1
# 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()))

def diff(l):
    m = max(l)
    return sorted(m - v for v in l)[1:]

s = sum(map(max, [a, b, c]))
sa, sb, sc = list(map(diff, [a, b, c]))
da, db, dc = [0], [0], [0]
q = [0]
while k > 0:
    while True:
        if len(sa) > 0 and (len(q) == 0 or q[0] > sa[0]):
            for v in [sa[0] + bb + cc for bb in db for cc in dc]:
                heapq.heappush(q, v)
            da.append(sa[0])
            sa = sa[1:]
        elif len(sb) > 0 and (len(q) == 0 or q[0] > sb[0]):
            for v in [sb[0] + aa + cc for aa in da for cc in dc]:
                heapq.heappush(q, v)
            db.append(sb[0])
            sb = sb[1:]
        elif len(sc) > 0 and (len(q) == 0 or q[0] > sc[0]):
            for v in [sc[0] + aa + bb for aa in da for bb in db]:
                heapq.heappush(q, v)
            dc.append(sc[0])
            sc = sc[1:]
        else:
            break
    v = heapq.heappop(q)
    print(s - v)
    k -= 1


# Optimized solution
import heapq

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

q = []
memo = set()
def qpush(q, ai, bi, ci):
    t = (-(a[ai] + b[bi] + c[ci]), ai, bi, ci)
    if not t in memo:
        memo.add(t)
        heapq.heappush(q, t)

qpush(q, len(a) - 1, len(b) - 1, len(c) - 1)
for _ in range(k):
    s, ai, bi, ci = heapq.heappop(q)
    if ai > 0:
        qpush(q, ai - 1, bi, ci)
    if bi > 0:
        qpush(q, ai, bi - 1, ci)
    if ci > 0:
        qpush(q, ai, bi, ci - 1)
    print(-s)
# Original 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)
AB=[]
append=AB.append
for i in range(min(K,X)):
    for j in range(min(K,Y)):
        append(A[i]+B[j])
AB.sort(reverse=True)
ABC=[]
appendd=ABC.append
for k in range(min(K,len(AB))):
    for l in range(min(K,Z)):
        appendd(AB[k]+C[l])
ABC.sort(reverse=True)
for m in range(K):
    print((ABC[m]))

# Optimized solution
import sys
def main():
    input=sys.stdin.readline
    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)

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

    ABC=[]
    appendd=ABC.append
    for k in range(min(K,len(AB))):
        for l in range(min(K,Z)):
            appendd(AB[k]+C[l])
    ABC.sort(reverse=True)

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

if __name__=="__main__":
    main()
# Original solution
x, y, z, k = list(map(int, input().split()))
k = min(x * y * z, k)
a = sorted(list(map(int, input().split())), reverse=True)[:k]
b = sorted(list(map(int, input().split())), reverse=True)[:k]
c = sorted(list(map(int, input().split())), reverse=True)[:k]
def f(a, b):
    results = []
    cnt = 0
    for i in a:
        for j in b:
            cnt += 1
            results.append(i + j)
    return results
ab_results = sorted(f(a, b), reverse=True)
results = sorted(f(c, ab_results[:k]), reverse=True)

print(("\n".join(map(str, results[:k]))))


# Optimized solution
x, y, z, k = list(map(int, input().split()))
k = min(x * y * z, k)
a = sorted(list(map(int, input().split())), reverse=True)[:k]
b = sorted(list(map(int, input().split())), reverse=True)[:k]
c = sorted(list(map(int, input().split())), reverse=True)[:k]
def f(a, b):
    return [i + j for i in a for j in b]
ab_results = sorted(f(a, b), reverse=True)
results = sorted(f(c, ab_results[:k]), reverse=True)

print(("\n".join(map(str, results[:k]))))
# Original 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()))

'''
考え方
各リストをソートして、前からk個分のみの要素にする
'''

'''
import math

cnt_num = math.ceil(pow(k, 1/3))

A = sorted(A,reverse=True)[:cnt_num]
B = sorted(B,reverse=True)[:cnt_num]
C = sorted(C,reverse=True)[:cnt_num]
'''
A = sorted(A,reverse=True)[:k]
B = sorted(B,reverse=True)[:k]
C = sorted(C,reverse=True)[:k]


ans_list = []
for a in A:
  for b in B:
    for c in C:
      ans_list.append(a+b+c)

ans_list.sort(reverse=True)
for ans in ans_list[:k]:
  print(ans)

# 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 = sorted(A,reverse=True)[:k]
B = sorted(B,reverse=True)[:k]
C = sorted(C,reverse=True)[:k]

list_ans = []
for index_a,a in enumerate(A):
  for index_b,b in enumerate(B):
    for index_c,c in enumerate(C):
      if (index_a + 1) * (index_b + 1) * (index_c + 1) > k:
        break
      list_ans.append(a+b+c)


list_ans.sort(reverse=True)
for i in list_ans[:k]:
  print(i)
# Original solution
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")

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

A = sorted(list( map(int, input().split()) ), reverse=True)	# 1 2 3 4 5 ...(ソート付き)
B = sorted(list( map(int, input().split()) ), reverse=True)	# 1 2 3 4 5 ...(ソート付き)
C = sorted(list( map(int, input().split()) ), reverse=True)	# 1 2 3 4 5 ...(ソート付き)

p(X,Y,Z,K)
p(A)
p(B)
p(C)

from itertools import product
L = list( product(A,B,C) )		# 上と同じ意味
#p(L)

from operator import itemgetter
#p( sorted(L, key=lambda x: (x[0]+x[1]+x[2])*(-1)) )  # 0 番目の要素 * 2 番目の要素でソート

iCount=0
for l in sorted(L, key=lambda x: (x[0]+x[1]+x[2])*(-1)):
	a = l[0]+l[1]+l[2]
	print(a)
	iCount+=1
	if iCount>=K: break



	

# Optimized solution
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")

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

A = sorted(list( map(int, input().split()) ), reverse=True)	# 1 2 3 4 5 ...(ソート付き)
B = sorted(list( map(int, input().split()) ), reverse=True)	# 1 2 3 4 5 ...(ソート付き)
C = sorted(list( map(int, input().split()) ), reverse=True)	# 1 2 3 4 5 ...(ソート付き)

p(X,Y,Z,K)
p(A)
p(B)
p(C)

#ABC=[]
#for a in range(X):
#	for b in range(Y):
#		if (a+b)>K: break
#		for c in range(Z):
#			if (a+b+c)>K: break
#			ABC.append(A[a]+B[b]+C[c])
#
#ABC.sort(reverse=True)

AB=[]
for a in range(X):
	for b in range(Y):
		if (a+b)>K: break
		AB.append(A[a]+B[b])

AB.sort(reverse=True)
p("AB=",AB)

ABC=[]
for ab in range(len(AB)):
	if ab>K: break
	for c in range(Z):
		if (ab+c)>K: break
		ABC.append(AB[ab]+C[c])

ABC.sort(reverse=True)
p("ABC=",ABC)

for k in range(K):
	print((ABC[k]))
# Original solution
import sys
input = lambda: sys.stdin.readline().rstrip()

def solve():

    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)

    sum_list = []
    seen_list = set()
    ans = []

    heappush(sum_list, (-(A[0]+B[0]+C[0]), 0, 0, 0))
    seen_list.add((0, 0, 0))

    while sum_list:
        s, i, j, k = heappop(sum_list)
        
        ans.append(-s)

        if i+1 < len(A) and (i+1, j, k) not in seen_list:
            heappush(sum_list, (-(A[i+1]+B[j]+C[k]), i+1, j, k))
            seen_list.add((i+1, j, k))

        if j+1 < len(B) and (i, j+1, k) not in seen_list:
            heappush(sum_list, (-(A[i]+B[j+1]+C[k]), i, j+1, k))
            seen_list.add((i, j+1, k))

        if k+1 < len(C) and (i, j, k+1) not in seen_list:
            heappush(sum_list, (-(A[i]+B[j]+C[k+1]), i, j, k+1))
            seen_list.add((i, j, k+1))

    for i in range(0, K):
        print((ans[i]))

if __name__ == "__main__":
    solve()

# Optimized solution
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():

    from heapq import heappop, heappush, heapify
    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)

    sum_list = []
    seen_list = set()
    ans = []

    heappush(sum_list, (-(A[0]+B[0]+C[0]), 0, 0, 0))
    seen_list.add((0, 0, 0))

    for _ in range(K):
        s, i, j, k = heappop(sum_list)
        
        ans.append(-s)

        if i+1 < len(A) and (i+1, j, k) not in seen_list:
            heappush(sum_list, (-(A[i+1]+B[j]+C[k]), i+1, j, k))
            seen_list.add((i+1, j, k))

        if j+1 < len(B) and (i, j+1, k) not in seen_list:
            heappush(sum_list, (-(A[i]+B[j+1]+C[k]), i, j+1, k))
            seen_list.add((i, j+1, k))

        if k+1 < len(C) and (i, j, k+1) not in seen_list:
            heappush(sum_list, (-(A[i]+B[j]+C[k+1]), i, j, k+1))
            seen_list.add((i, j, k+1))

    for i in range(0, K):
        print((ans[i]))

if __name__ == "__main__":
    main()
# Original 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)

delicious_list = []
for a in A[:min((1000,len(A)))]:
    for b in B[:min((1000,len(B)))]:
        for c in C[:min((1000,len(C)))]:
            delicious_list.append(a+b+c)
delicious_list.sort(reverse=True)
for i in range(K):
    print((delicious_list[i]))

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

delicious_list = []
for i in range(len(A)):
    for j in range(len(B)):
        for k in range(len(C)):
            if i*j*k>=K: continue
            delicious_list.append(A[i]+B[j]+C[k])
delicious_list.sort(reverse=True)
for i in range(K):
    print((delicious_list[i]))
# Original solution
import sys

input = sys.stdin.readline

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)
tmp_list = [a+b for a in a_list for b in b_list]
tmp_list.sort(reverse=True)
honest_list = [tmp+c for tmp in tmp_list for c in c_list]
honest_list.sort(reverse=True)
for h in honest_list[:k]:
    print(h)


# Optimized solution
import sys

input = sys.stdin.readline

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)
tmp_list = [a+b for a in a_list for b in b_list]
tmp_list.sort(reverse=True)
honest_list = [tmp+c for tmp in tmp_list[:k] for c in c_list]
honest_list.sort(reverse=True)
for h in honest_list[:k]:
    print(h)
# Original 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()))

l=[]
for s in a:
    for t in b:
        l.append(s+t)
l.sort(reverse=True)
n=[]
for s in l[:k+1]:
    for t in c:
        n.append(s+t)
n.sort(reverse=True)
for i in range(k):
    print((n[i]))

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

l=[]
for s in range(x):
    for t in range(y):
        for u in range(z):
            if (s+1)*(t+1)*(u+1)<= k:
                l.append(a[s]+b[t]+c[u])
            else:
                break
l.sort(reverse=True)
for i in range(k):
    print((l[i]))
# Original solution

from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


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


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)

kouho = []
all_set = []
heapq.heappush(kouho, [-(A[0] + B[0] + C[0]), 0, 0, 0])
all_set.append([-(A[0] + B[0] + C[0]), 0, 0, 0])
for i in range(K):
	comb = heapq.heappop(kouho)
	print((-comb[0]))
	if comb[1] < X - 1 and not [-(A[comb[1] + 1] + B[comb[2]] + C[comb[3]]), comb[1] + 1, comb[2], comb[3]] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1] + 1] + B[comb[2]] + C[comb[3]]), comb[1] + 1, comb[2], comb[3]])
		all_set.append([-(A[comb[1] + 1] + B[comb[2]] + C[comb[3]]), comb[1] + 1, comb[2], comb[3]])
	if comb[2] < Y - 1 and not [-(A[comb[1]] + B[comb[2] + 1] + C[comb[3]]), comb[1], comb[2] + 1, comb[3]] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1]] + B[comb[2] + 1] + C[comb[3]]), comb[1], comb[2] + 1, comb[3]])
		all_set.append([-(A[comb[1]] + B[comb[2] + 1] + C[comb[3]]), comb[1], comb[2] + 1, comb[3]])
	if comb[3] < Z - 1 and not [-(A[comb[1]] + B[comb[2]] + C[comb[3] + 1]), comb[1], comb[2], comb[3] + 1] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1]] + B[comb[2]] + C[comb[3] + 1]), comb[1], comb[2], comb[3] + 1])
		all_set.append([-(A[comb[1]] + B[comb[2]] + C[comb[3] + 1]), comb[1], comb[2], comb[3] + 1])




# Optimized solution


from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


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


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)

kouho = []
all_set = set()
heapq.heappush(kouho, [-(A[0] + B[0] + C[0]), 0, 0, 0])
all_set.add(0)
for i in range(K):
	comb = heapq.heappop(kouho)
	print((-comb[0]))
	if comb[1] < X - 1 and not (comb[1] + 1)*Y*Z + comb[2]*Z + comb[3] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1] + 1] + B[comb[2]] + C[comb[3]]), comb[1] + 1, comb[2], comb[3]])
		all_set.add((comb[1] + 1)*Y*Z + comb[2]*Z + comb[3])
	if comb[2] < Y - 1 and not comb[1]*Y*Z + (comb[2] + 1)*Z + comb[3] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1]] + B[comb[2] + 1] + C[comb[3]]), comb[1], comb[2] + 1, comb[3]])
		all_set.add(comb[1]*Y*Z + (comb[2] + 1)*Z + comb[3])
	if comb[3] < Z - 1 and not comb[1]*Y*Z + comb[2]*Z + comb[3] + 1 in all_set:
		heapq.heappush(kouho,  [-(A[comb[1]] + B[comb[2]] + C[comb[3] + 1]), comb[1], comb[2], comb[3] + 1])
		all_set.add(comb[1]*Y*Z + comb[2]*Z + comb[3] + 1)
# Original solution
from itertools import product
x, y, z, k = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
zs = list(map(int, input().split()))
# xs.sort(reverse=True)
# ys.sort(reverse=True)
# zs.sort(reverse=True)
ans_list = []
for i,a in enumerate(list(product(xs,ys,zs))):
    ans_list.append(sum(a))
    
ans_list.sort(reverse=True)
for i,ans in enumerate(ans_list):
    print(ans)
    if i == k - 1:
        break

# Optimized solution
from itertools import product
x, y, z, k = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
zs = list(map(int, input().split()))

xy_list = []
for i,xy in enumerate(list(product(xs,ys))):
    xy_list.append(sum(xy))

xy_list.sort(reverse=True)
xy_list = xy_list[:k]

ans_list = []
for i,xyz in enumerate(list(product(xy_list,zs))):
    ans_list.append(sum(xyz))
    
ans_list.sort(reverse=True)
ans_list = ans_list[:k]

for ans in ans_list:
    print(ans)
# Original 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()))

AB = list()
for i in A:
    for j in B:
        AB.append(i+j)

AB.sort(reverse=True)
ABC = list()

for i in AB[:K]:
    for j in C:
        ABC.append(i+j)

ABC.sort(reverse=True)
for i in range(K):
    print((ABC[i]))


# Optimized solution
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 = list()
for i in range(X):
    for j in range(Y):
        if (i+1)*(j+1) > K:
            break
        else:
            for k in range(Z):
                if (i+1)*(j+1)*(k+1) > K:
                    break
                else:
                    ans.append(A[i]+B[j]+C[k])

ans.sort(reverse=True)
for i in range(K):
    print((ans[i]))
# Original 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()))
ans = [p+q+r for p in a for q in b for r in c]

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


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

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

for i in range(k):
    print((ans[i]))
# Original 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()))

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

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


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

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

for i in range(k):
    print((ans[i]))
# Original solution
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()))

'''
必ず3つからそれぞれ1つずつ取らないといけないので、a,bの組み合わせの大きい順
とa,b,cの組の大きい順で見たときの(a,b)の順は一致している
a,bの組み合わせのうち上からk番目以降は考える必要がない
'''
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
ab = ab[:k]
rec = []
for i in range(min(x*y, k)):
    for j in range(z):
        rec.append(ab[i] + c[j])

rec.sort(reverse=True)
rec = rec[:k]
print(*rec, sep='\n')


# Optimized solution
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 range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
ab = ab[:k]
rec = []
for i in range(min(x*y, k)):
    for j in range(z):
        rec.append(ab[i] + c[j])

rec.sort(reverse=True)
rec = rec[:k]
print(*rec, sep='\n')
# 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(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
for a in A:
	for b in B:
		for c in C:
			ans.append(a+b+c)

ans.sort(reverse=True)
for i in range(K):
	print((ans[i]))

# Optimized 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(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
b=0
c=0
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:
				ans.append(A[a]+B[b]+C[c])
			else:
				break

ans.sort(reverse=True)
for i in range(K):
	print((ans[i]))