CodeEff/ECCO huggingface dataset:
# Original solution
X,Y,Z,K=[int(s) for s in input().split()]
xls=sorted([int(s) for s in input().split()],reverse=True)
yls=sorted([int(s) for s in input().split()],reverse=True)
zls=sorted([int(s) for s in input().split()],reverse=True)
xyls=[]
for x in xls[:K]:
  for y in yls[:K]:
    xyls.append(x+y)
xyls=sorted(xyls,reverse=True)
cake=[]
for xy in xyls[:K]:
  for z in zls[:K]:
    cake.append(xy+z)
cake=sorted(cake,reverse=True)
for i in range(K):
  print((cake[i]))

# Optimized solution
X,Y,Z,K=[int(s) for s in input().split()]
xls=sorted([int(s) for s in input().split()],reverse=True)
yls=sorted([int(s) for s in input().split()],reverse=True)
zls=sorted([int(s) for s in input().split()],reverse=True)
cake=[]
for a in range(X):
  for b in range(Y):
    ab=(a+1)*(b+1)
    for c in range(Z):
      if ab*(c+1)>K:
        break
      cake.append(xls[a]+yls[b]+zls[c])
    if ab>K:
      break
cake=sorted(cake,reverse=True)
for i in range(K):
  print((cake[i]))
# Original solution
import sys
from bisect import bisect_left,bisect_right,insort
input = sys.stdin.readline

def main():
    x,y,z,K=list(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,r=a[0]+b[0]+c[0],a[-1]+b[-1]+c[-1]
    while l+1<r:
        ans=0
        m=(l+r)//2
        for i in range(x-1,-1,-1):
            if a[i]>=m:
                ans+=y*z
                continue
            for j in range(y-1,-1,-1):
                if a[i]+b[j]>=m:
                    ans+=z
                    continue
                for k in range(z-1,-1,-1):
                    if a[i]+b[j]+c[k]>=m:
                        ans+=1
                        continue
                    else:
                        break
        if ans>=K:
            l=m
        else:
            r=m
    s=[0]
    for i in range(x-1,-1,-1):
        for j in range(y-1,-1,-1):
            for k in range(z-1,-1,-1):
                if a[i]+b[j]+c[k]>=l:
                    s.append(a[i]+b[j]+c[k])
                    continue
                else:
                    break
    s.sort()
    for i in range(len(s)-1,0,-1):
        print((s[i]))

if __name__ == '__main__':
    main()

# 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()))
 
AB = [a + b for a in A for b in B]
AB.sort(reverse=True)
AB = AB[:k]
 
ABC = [ab + c for ab in AB for c in C]
ABC.sort(reverse=True)
ABC = ABC[:k]
 
print(('\n'.join(map(str, ABC))))
# Original solution
import itertools

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 = sorted(A)[::-1][:K]
B = sorted(B)[::-1][:K]
C = sorted(C)[::-1][:K]

T = [A, B]
score = []
for cand in itertools.product(*T):
  score.append(sum(cand))
  
T = [sorted(score)[::-1][:K], C]
res = []
for cand in itertools.product(*T):
  res.append(sum(cand))

res = sorted(res)[::-1][:K]
for i in range(K):
    print((res[i]))

# Optimized solution
import itertools

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)

D = [a+b for a,b in itertools.product(A[:K], B[:K])]
D.sort(reverse=True)

E = [c+d for c,d in itertools.product(C[:K], D[:K])]
E.sort(reverse=True)

for i in range(K):
    print((E[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()))

L = []

for i in range(len(A)):
    for j in range(len(B)):
        L.append(A[i] + B[j])

L.sort(reverse=True)

ans_list = [0] * (10000000)

for i in range(min(K,len(L))):
    for j in range(len(C)):
        ans_list.append(L[i] + C[j])

ans_list.sort(reverse=True)


for i in range(K):
    print((ans_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()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print((abc[i]))
# Original solution
import heapq
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(" ")]

AB=[]
for a in A:
    for b in B:
        AB.append(a+b)

AB=heapq.nlargest(K,AB)
ABC=[]
for ab in AB:
    for c in C:
        ABC.append(ab+c)

for cake in heapq.nlargest(K,ABC):
    print(cake)


# 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(" ")]
 
AB=[]
 
A=sorted(A,reverse=True)[:K:]
B=sorted(B,reverse=True)[:K:]
C=sorted(C,reverse=True)[:K:]
for a in A:
    for b in B:
        AB.append(a+b)
 
AB=sorted(AB,reverse=True)[:K:]
 
ABC=[]
for ab in AB:
    for c in C:
        ABC.append(ab+c)
 
ABC=sorted(ABC,reverse=True)[:K:]
 
 
for abc in ABC:
    print(abc)
# 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()))
l = []
for i in a:
    for j in b:
        l.append(i + j)
c.sort(reverse=True)
l.sort(reverse=True)
l2 = []
for i in c:
    for j in l:
        l2.append(i + j)
l2.sort(reverse=True)
print(*l2[:k], 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()))
l = []
for i in a:
    for j in b:
        l.append(i + j)
c.sort(reverse=True)
l.sort(reverse=True)
l = l[:k]
l2 = []
for i in c:
    for j in l:
        l2.append(i + j)
l2.sort(reverse=True)
print(*l2[:k], sep="\n")
# Original solution
X,Y,Z,K = [int(x) for x in 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()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()
li=[]
inf = 10**11
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):
                li.append(A[i]+B[j]+C[k])
li.sort()
li.reverse()
for i in li[:K]:
    print(i)

# Optimized solution
X,Y,Z,K = [int(x) for x in 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()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()
li=[]
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):
                li.append(A[i]+B[j]+C[k])
li.sort()
li.reverse()
for i in li[:K]:
    print(i)
# Original solution
from heapq import heapify,heappop,heappush

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)
que=[[-(A[0]+B[0]+C[0]),0,0,0]];heapify(que)
Count=[[[0]*(Z+1) for i in range(Y+1)] for j in range(X+1)]

for i in range(K):
    p=heappop(que)
    print((-p[0]))
    if p[1]<X-1 and Count[p[1]+1][p[2]][p[3]]==0:
        heappush(que,[-sum([A[p[1]+1],B[p[2]],C[p[3]]]),p[1]+1,p[2],p[3]])
        Count[p[1]+1][p[2]][p[3]]+=1
    if p[2]<Y-1 and Count[p[1]][p[2]+1][p[3]]==0:
        heappush(que,[-sum([A[p[1]],B[p[2]+1],C[p[3]]]),p[1],p[2]+1,p[3]])
        Count[p[1]][p[2]+1][p[3]]+=1
    if p[3]<Z-1 and Count[p[1]][p[2]][p[3]+1]==0:
        heappush(que,[-sum([A[p[1]],B[p[2]],C[p[3]+1]]),p[1],p[2],p[3]+1])
        Count[p[1]][p[2]][p[3]+1]+=1

# Optimized solution
from heapq import heapify,heappop,heappush

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)
que=[[-(A[0]+B[0]+C[0]),0,0,0]];heapify(que)
s=set()

for i in range(K):
    p=heappop(que)
    print((-p[0]))
    if p[1]<X-1 and not (p[1]+1,p[2],p[3]) in s:
        heappush(que,[-sum([A[p[1]+1],B[p[2]],C[p[3]]]),p[1]+1,p[2],p[3]])
        s.add((p[1]+1,p[2],p[3]))
    if p[2]<Y-1 and not (p[1],p[2]+1,p[3]) in s:
        heappush(que,[-sum([A[p[1]],B[p[2]+1],C[p[3]]]),p[1],p[2]+1,p[3]])
        s.add((p[1],p[2]+1,p[3]))
    if p[3]<Z-1 and not (p[1],p[2],p[3]+1) in s:
        heappush(que,[-sum([A[p[1]],B[p[2]],C[p[3]+1]]),p[1],p[2],p[3]+1])
        s.add((p[1],p[2],p[3]+1))
# Original solution
from itertools import groupby
from operator import itemgetter

x,y,z,k = (int(x) for x in 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()]
# key, group
ga0 = [{'val':key, 'cnt':len(list(group))} for key, group in groupby(a)]
ga = list(reversed(sorted(ga0, key=itemgetter('val'))))
gb = list(reversed(sorted([{'val':key, 'cnt':len(list(group))} for key, group in groupby(b)], key=itemgetter('val'))))
gc = list(reversed(sorted([{'val':key, 'cnt':len(list(group))} for key, group in groupby(c)], key=itemgetter('val'))))

lga, lgb = len(ga), len(gb)
ia,ib = 0,0
ca,cb = ga[0]['cnt'],gb[0]['cnt']
while ca*cb < k:
    if ia == lga-1 and ib == lgb-1:
        break
    elif ia == lga-1:
        ib += 1
        cb += gb[ib]['cnt']
    elif ib == lgb-1:
        ia += 1
        ca += ga[ia]['cnt']
    elif ga[ia+1]['val'] + gb[ib]['val'] >= ga[ia]['val'] + gb[ib+1]['val']:
        ia += 1
        ca += ga[ia]['cnt']
    else:
        ib += 1
        cb += gb[ib]['cnt']
d = []
for va in ga:
    for vb in gb:
        d.append((va['val']+vb['val'],va['cnt']*vb['cnt']))
gd0 = [{'val':key, 'cnt':sum(c_ for _, c_ in list(group))} for key, group in groupby(d,itemgetter(0))]
gd = list(reversed(sorted(gd0, key=itemgetter('val'))))[:k]

lgc, lgd = len(gc), len(gd)
ic,id = 0,0
cc,cd = gc[0]['cnt'],gd[0]['cnt']
while cc*cd < k:
    if ic == lgc-1 and id == lgd-1:
        break
    elif ic == lgc-1:
        id += 1
        cd += gd[id]['cnt']
    elif id == lgd-1:
        ic += 1
        cc += gc[ic]['cnt']
    elif gc[ic+1]['val'] + gd[id]['val'] >= gc[ic]['val'] + gd[id+1]['val']:
        ic += 1
        cc += gc[ic]['cnt']
    else:
        id += 1
        cd += gd[id]['cnt']
r = []
for vc in gc:
    for vd in gd:
        r.append((vc['val']+vd['val'],vc['cnt']*vd['cnt']))
gr0 = [{'val':key, 'cnt':sum(c_ for _, c_ in list(group))} for key, group in groupby(r,itemgetter(0))]
gr = list(reversed(sorted(gr0, key=itemgetter('val'))))[:k]
i = 0
for vr in gr:
    for j in range(vr['cnt']):
        print((vr['val']))
        i += 1
        if i == k:
            exit


# Optimized solution
import heapq
x,y,z,k = (int(x) for x in 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)
# heap
h = []
g = set()
heapq.heappush(h, (-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    q,ia,ib,ic = heapq.heappop(h)
    print((-q))
    ja,jb,jc = ia+1,ib,ic
    if ja<x and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    ja,jb,jc = ia,ib+1,ic
    if jb<y and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    ja,jb,jc = ia,ib,ic+1
    if jc<z and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
# Original solution
import sys
import heapq

input = sys.stdin.readline


def main():
    X, Y, Z, K = list(map(int, input().split()))
    A = list([-int(x) for x in input().split()])
    B = list([-int(x) for x in input().split()])
    C = list([-int(x) for x in input().split()])

    A.sort()
    B.sort()
    C.sort()

    p_queue = [(A[0] + B[0] + C[0], 0, 0, 0)]
    appear = [[[False for _ in range(Z)] for _ in range(Y)] for _ in range(X)]
    appear[0][0][0] = True
    ans = []
    while len(ans) < K:
        s, i_A, i_B, i_C = heapq.heappop(p_queue)
        ans.append(-s)
        if i_A < X - 1 and not appear[i_A + 1][i_B][i_C]:
            appear[i_A + 1][i_B][i_C] = True
            t = s - A[i_A] + A[i_A + 1]
            heapq.heappush(p_queue, (t, i_A + 1, i_B, i_C))
        if i_B < Y - 1 and not appear[i_A][i_B + 1][i_C]:
            appear[i_A][i_B + 1][i_C] = True
            t = s - B[i_B] + B[i_B + 1]
            heapq.heappush(p_queue, (t, i_A, i_B + 1, i_C))
        if i_C < Z - 1 and not appear[i_A][i_B][i_C + 1]:
            appear[i_A][i_B][i_C + 1] = True
            t = s - C[i_C] + C[i_C + 1]
            heapq.heappush(p_queue, (t, i_A, i_B, i_C + 1))

    print(("\n".join(map(str, ans))))


if __name__ == "__main__":
    main()


# Optimized solution
import sys
import heapq

input = sys.stdin.readline


def main():
    X, Y, Z, K = list(map(int, input().split()))
    A = list([-int(x) for x in input().split()])
    B = list([-int(x) for x in input().split()])
    C = list([-int(x) for x in input().split()])

    A.sort()
    B.sort()
    C.sort()

    p_queue = [(A[0] + B[0] + C[0], 0, 0, 0)]
    visited = set()
    visited.add((0, 0, 0))
    ans = []
    while len(ans) < K:
        s, i_A, i_B, i_C = heapq.heappop(p_queue)
        ans.append(-s)
        if i_A < X - 1 and (i_A + 1, i_B, i_C) not in visited:
            visited.add((i_A + 1, i_B, i_C))
            t = s - A[i_A] + A[i_A + 1]
            heapq.heappush(p_queue, (t, i_A + 1, i_B, i_C))
        if i_B < Y - 1 and (i_A, i_B + 1, i_C) not in visited:
            visited.add((i_A, i_B + 1, i_C))
            t = s - B[i_B] + B[i_B + 1]
            heapq.heappush(p_queue, (t, i_A, i_B + 1, i_C))
        if i_C < Z - 1 and (i_A, i_B, i_C + 1) not in visited:
            visited.add((i_A, i_B, i_C + 1))
            t = s - C[i_C] + C[i_C + 1]
            heapq.heappush(p_queue, (t, i_A, i_B, i_C + 1))

    print(("\n".join(map(str, ans))))


if __name__ == "__main__":
    main()
# Original solution
import sys
readline = sys.stdin.readline

X,Y,Z,K = list(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)

# AとBを組み合わせたケーキの上位K位を作る
AB = []
for a in range(len(A)):
  for b in range(len(B)):
    AB += [A[a] + B[b]]
    
AB = sorted(AB,reverse = True)[:K]

# ABとCを組み合わせたケーキの上位K位を作る
ans = []
for ab in range(len(AB)):
  for c in range(len(C)):
    ans += [AB[ab] + C[c]]
    
ans = sorted(ans,reverse = True)[:K]
for a in ans:
  print(a)

# Optimized solution
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")
# Original solution
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)
AB=[]
for a in A:
	for b in B:
		AB.append(a+b)
ABC=[]
for ab in sorted(AB, reverse=True)[:K]:
	for c in C:
		ABC.append(ab+c)
for abc in sorted(ABC, reverse=True)[:K]:
	print(abc)


# 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()))
AB=[]
for a in A:
	for b in B:
		AB.append(a+b)
ABC=[]
for ab in sorted(AB, reverse=True)[:K]:
	for c in C:
		ABC.append(ab+c)
for abc in sorted(ABC, reverse=True)[:K]:
	print(abc)
# Original solution
import itertools

X, Y, Z, K = [int(x) for x in 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()]

list_ = [a+b+c for (a,b,c) in itertools.product(A, B, C)]
list_.sort(reverse=True)
for N in list_[:K]:
  print(N)

# Optimized solution
import itertools

X, Y, Z, K = [int(x) for x in 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)
 
list_ = [b+c for (b,c) in itertools.product(B, C)]
list_.sort(reverse=True)
 
list__ = [ab+c for (ab,c) in itertools.product(list_[:K], A)]
list__.sort(reverse=True)
for N in list__[:K]:
  print(N)
# Original solution
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(X, Y, Z, K, As, Bs, Cs):
    ABs = []
    for A in As:
        for B in Bs:
            ABs.append(A + B)
    ABs.sort(reverse=True)
    ABCs = []
    for i in range(min(X * Y, K)):
        AB = ABs[i]
        for C in Cs:
            ABCs.append(AB + C)
    ABCs.sort(reverse=True)
    for i in range(K):
        print((ABCs[i]))


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    X, Y, Z, K = list(map(int, input().split()))
    As = [int(i) for i in input().split()]
    Bs = [int(i) for i in input().split()]
    Cs = [int(i) for i in input().split()]
    # import random
    # X, Y, Z, K = 1000,1000,1000,3000
    # As = [random.randint(1, 10 ** 10) for _ in range(X)]
    # Bs = [random.randint(1, 10 ** 10) for _ in range(Y)]
    # Cs = [random.randint(1, 10 ** 10) for _ in range(Z)]
    solve(X, Y, Z, K, As, Bs, Cs)


# Optimized solution
# 解説を参考に作成

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(X, Y, Z, K, As, Bs, Cs):
    ABs = []
    for A in As:
        for B in Bs:
            ABs.append(A + B)
    ABs.sort(reverse=True)
    ABCs = []
    for i in range(min(X * Y, K)):
        AB = ABs[i]
        for C in Cs:
            ABCs.append(AB + C)
    ABCs.sort(reverse=True)
    for i in range(K):
        print((ABCs[i]))


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    X, Y, Z, K = list(map(int, input().split()))
    As = [int(i) for i in input().split()]
    Bs = [int(i) for i in input().split()]
    Cs = [int(i) for i in input().split()]
    # import random
    # X, Y, Z, K = 1000,1000,1000,3000
    # As = [random.randint(1, 10 ** 10) for _ in range(X)]
    # Bs = [random.randint(1, 10 ** 10) for _ in range(Y)]
    # Cs = [random.randint(1, 10 ** 10) for _ in range(Z)]
    solve(X, Y, Z, K, As, Bs, Cs)
# Original solution
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	X, Y, Z, K = list(map(int, input().split(" ")))
	As = []
	Bs = []
	Cs = []
	As = input().split()
	As = [int(s) for s in As]
	Bs = input().split()
	Bs = [int(s) for s in Bs]
	Cs = input().split()
	Cs = [int(s) for s in Cs]

	As.sort(reverse=True)
	Bs.sort(reverse=True)
	Cs.sort(reverse=True)

	As = As[:K]
	Bs = Bs[:K]
	Cs = Cs[:K]

	ans = []
	for i, val in enumerate(As):
		for j, vol in enumerate(Bs):
			for k, ogi in enumerate(Cs):
				ans.append(val+vol+ogi)

	ans.sort(reverse=True)
	for i in range(K):
		print((ans[i]))
	
if __name__ == "__main__":
	main()
	

# Optimized solution
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	X, Y, Z, K = list(map(int, input().split(" ")))
	As = []
	Bs = []
	Cs = []
	As = input().split()
	As = [int(s) for s in As]
	Bs = input().split()
	Bs = [int(s) for s in Bs]
	Cs = input().split()
	Cs = [int(s) for s in Cs]

	As.sort(reverse=True)
	Bs.sort(reverse=True)
	Cs.sort(reverse=True)

	ans1 = []
	for i, val in enumerate(As):
		for j, vol in enumerate(Bs):
			ans1.append(val+vol)

	ans1.sort(reverse=True)
	ans1 = ans1[:3000]

	ans2 = []
	for i, val in enumerate(ans1):
		for j, vol in enumerate(Cs):
			ans2.append(val+vol)

	ans2.sort(reverse=True)
	for i in range(K):
		print((ans2[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()))
D = []
E = []
for i in range(x):
  for j in range(y):
    D.append(A[i]+B[j])
for i in range(z):
  for j in range(len(D)):
    E.append(C[i]+D[j])
print(("\n".join(map(str,sorted(E)[::-1][:k]))))


# Optimized solution
x, y, z, k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list((list(map(int,input().split()))))
D = []
E = []
for i in range(x):
  for j in range(y):
    D.append(A[i]+B[j])
D.sort()
for i in range(z):
  for j in range(min(len(D),k)):
    E.append(C[i]+D[::-1][j])
print(("\n".join(map(str,sorted(E)[::-1][: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((list(map(int,input().split()))))
D = []
E = []
for i in range(x):
  for j in range(y):
    D.append(A[i]+B[j])
D = sorted(D,reverse=True)[:k]
for j in range(len(D)):
  for i in range(z):
    E.append(C[i]+D[j])
E = sorted(E, reverse=True)
for i in range(k):
  print((E[i]))

# Optimized solution
x, y, z, k = [int(n) for n in input().split()]
va = sorted([int(n) for n in input().split()], reverse=True)
vb = sorted([int(n) for n in input().split()], reverse=True)
xy = min(x*y, k)
vab = (sorted([a + b for a in va for b in vb], reverse=True))[:xy]
vc = sorted([int(n) for n in input().split()], reverse=True)
xyz = min(x*y*z, k)
print(*((sorted([ab + c for ab in vab for c in vc], reverse=True))[:xyz]), sep="\n")