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: interview

Starter code:

Solutions:


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(X):
    if (i+1) > K: break
    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
            ans.append(A[i]+B[j]+C[k])

ans.sort(reverse=True)

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


import heapq as hq
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 a in A:
    for b in B:
        hq.heappush(ab, -a-b)
abc = []
cnt = 0
while cnt < k and ab:
    cnt += 1
    a = hq.heappop(ab)
    for b in C:
        hq.heappush(abc, a-b)
cnt = 0
while cnt < k:
    print(-hq.heappop(abc))
    cnt += 1

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


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

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


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

"""
priority-queue
"""
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])   
#ret=[] 
for i in range(rank):
    poped=queue.pop(0)
    #print(str(i+1)+":"+str(poped[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)):
                #print("to cmp")
                #print(queue[k],to_append)
                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
            #print(Done)    
            if Done==True:
                queue.append(to_append)    
            #print("print Queue")
            #for k in range(len(queue)):
            #    print(queue[k])
    if len(queue)>rank-i-1:
        queue=queue[:(rank-i-1)]
        #print("cut")
    #print("print Queue")    
    #for j in range(len(queue)):
    #            print(queue[j])    




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

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


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

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

# D - Cake 123

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

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


x, y, z, k = map(int, input().split())
alst = list(map(int, input().split()))
blst = list(map(int, input().split()))
clst = list(map(int, input().split()))
alst.sort(reverse = True)
blst.sort(reverse = True)
clst.sort(reverse = True)
ans = []
for i in range(x):
    for j in range(y):
        if i * j > k:
            break
        for l in range(z):
            if i * j * l > k:
                break
            ans.append(alst[i] + blst[j] + clst[l])
ans.sort(reverse = True)
print(*ans[:k], sep = "\n")

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  # 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.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
dic={}
dic[(0,0,0)]=1
lst =[(-(A[0]+B[0]+C[0]),0,0,0)]
heapq.heapify(lst)
for r in range(K):
 a=lst[0][1]
 b=lst[0][2]
 c=lst[0][3]
 print(lst[0][0]*(-1))
 heapq.heappop(lst)
 if a<X-1 :
  if (a+1,b,c) not in dic:
   heapq.heappush(lst, (-(A[a+1]+B[b]+C[c]),a+1,b,c))
   dic[(a+1,b,c)]=1
 if b<Y-1 :
  if (a,b+1,c) not in dic:
   heapq.heappush(lst, (-(A[a]+B[b+1]+C[c]),a,b+1,c))
   dic[(a,b+1,c)]=1
 if c<Z-1 :
  if (a,b,c+1) not in dic:
   heapq.heappush(lst, (-(A[a]+B[b]+C[c+1]),a,b,c+1))
   dic[(a,b,c+1)]=1

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

import heapq  # 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.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
check=[[0,0,0]]
lst =[(-(A[0]+B[0]+C[0]),0,0,0)]
heapq.heapify(lst)
for r in range(K):
 a=lst[0][1]
 b=lst[0][2]
 c=lst[0][3] 
 print(lst[0][0]*(-1))
 heapq.heappop(lst)
 if a<X-1 :
  if [a+1,b,c] not in check:
   heapq.heappush(lst, (-(A[a+1]+B[b]+C[c]),a+1,b,c))
   check.append([a+1,b,c])
 if b<Y-1 :
  if [a,b+1,c] not in check:
   heapq.heappush(lst, (-(A[a]+B[b+1]+C[c]),a,b+1,c))
   check.append([a,b+1,c])
 if c<Z-1 :
  if [a,b,c+1] not in check:
   heapq.heappush(lst, (-(A[a]+B[b]+C[c+1]),a,b,c+1))
   check.append([a,b,c+1])

from heapq import heapify,heappop,heappush

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

import sys
from heapq import heappop, heappush

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)

    hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]

    ans = [0] * K
    added = {(0, 0, 0)}

    for idx in range(K):
        taste, i, j, k = heappop(hq)
        ans[idx] = -taste
        if i < X - 1 and (i + 1, j, k) not in added:
            heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
            added.add((i + 1, j, k))
        if j < Y - 1 and (i, j + 1, k) not in added:
            heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
            added.add((i, j + 1, k))
        if k < Z - 1 and (i, j, k + 1) not in added:
            heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
            added.add((i, j, k + 1))

    print(*ans, sep='\n')
    return


def __starting_point():
    main()

__starting_point()

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 = []
s = []

for i in A:
    for j in B:
        e.append(i+j)
e = sorted(e, reverse=True)

if K<len(e):
    e = e[0:K]

for i in e:
    for j in C:
        s.append(i+j)

s = sorted(s, reverse=True)

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

#!/usr/bin/env python3

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 i in a:
#     for j in b:
#         ab.append(i+j)
# ab.sort(reverse=True)

# ab = ab[:k]

# abc = []
# for i in ab:
#     for j in c:
#         abc.append(i+j)
# abc.sort(reverse=True)

# for i in range(k):
#     print(abc[i])

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
            # print(i, j, l)
            abc.append(a[i-1]+b[j-1]+c[l-1])

# print(abc)
# print(k)
abc.sort(reverse=True)
for i in range(k):
    print((abc[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 = 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)]
    ans = [0] * K
    seen = {(0, 0, 0)}

    for idx in range(K):
        s, i, j, k = heappop(hq)
        ans[idx] = -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(*ans, sep='\n')
    return


def __starting_point():
    main()

__starting_point()

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)

# Heapq的なのでぶっこみPopしてればよい
# そのかわり全パターン最初からぶち込むのはむりなので、popしたindexをもとに候補となる対象をpushする必要がある
# ただし容易に重複投入しうるので、投入済みパターンを覚えておくのかな…。historyに含まれてたらSKIP。
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)
  


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

# O(klog(k))解法 多分...
import sys
from heapq import heappush,heapify,heappop
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()))

def make_kth(A, B):
    n, m = len(A), len(B)
    A.sort(reverse=1)
    B.sort(reverse=1)
    q = [(-A[0] - B[0], 0, 0)]
    r=[]
    for _ in range(min(k, n * m)):
        v, s, t = heappop(q)
        r.append(-v)
        if t + 1 < m:
            heappush(q, (-A[s] - B[t + 1], s, t + 1))
        if t == 0 and s + 1 < n:
            heappush(q, (-A[s + 1] - B[0], s + 1, 0))
    return r

r = make_kth(a, b)
r = make_kth(c, r)
print(*r,sep="\n")

# D - Cake 123

import heapq
import itertools
from collections import defaultdict

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 = []
hqAns = []
d = defaultdict(int)

heapq.heappush(hq, ((A[0]+B[0]+C[0])*-1, 0, 0, 0))
d[(0,0,0)] = 1

while len(hqAns)<k :
    val, l, m, n = heapq.heappop(hq)
    heapq.heappush(hqAns, val)
 
    if d[(l+1, m, n)]==0 and l+1 < x:
        heapq.heappush(hq, ((A[l+1]+B[m]+C[n])*-1, l+1, m, n))
        d[(l+1, m, n)] = 1

    if d[(l, m+1, n)]==0 and m+1 < y:
        heapq.heappush(hq, ((A[l]+B[m+1]+C[n])*-1, l, m+1, n))
        d[(l, m+1, n)] = 1
 
    if d[(l, m, n+1)]==0 and n+1 < z:
        heapq.heappush(hq, ((A[l]+B[m]+C[n+1])*-1, l, m, n+1))
        d[(l, m, n+1)] = 1

for i in range(k):
    print((heapq.heappop(hqAns)*-1))

'''
# ans.2 #

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)

'''

'''

# ans.1 #

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

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]
    #print(-max[0],i,j,k)
    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()


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

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

import heapq
V={(0,0,0)}
Q=[(-(A[0]+B[0]+C[0]),0,0,0)]
heapq.heapify(Q)

def isIn(tup):
    return tup[0]<x and tup[1]<y and tup[2]<z

for i in range(k):
    now=heapq.heappop(Q)
    print(-now[0])
    nex=(now[1]+1,now[2],now[3])
    if not nex in V and isIn(nex):
        V.add(nex)
        heapq.heappush(Q,(-(A[nex[0]]+B[nex[1]]+C[nex[2]]),)+nex)
    nex=(now[1],now[2]+1,now[3])
    if not nex in V and isIn(nex):
        V.add(nex)
        heapq.heappush(Q,(-(A[nex[0]]+B[nex[1]]+C[nex[2]]),)+nex)
    nex=(now[1],now[2],now[3]+1)
    if not nex in V and isIn(nex):
        V.add(nex)
        heapq.heappush(Q,(-(A[nex[0]]+B[nex[1]]+C[nex[2]]),)+nex)

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

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



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)

# (sum, idx of a, b, c)

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

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



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)

sum = []
for x in range(X):
    for y in range(Y):
        for z in range(Z):
            if (x+1)*(y+1)*(z+1) <= K:
                sum.append(A[x] + B[y] + C[z])
            else:
                break

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

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
def main():
    def push(i, j, k):
        nonlocal ADD, H
        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()))
    A = sorted([-int(x) for x in input().split()])
    B = sorted([-int(x) for x in input().split()])
    C = sorted([-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()

from itertools import product
from heapq import *

X,Y,Z,K,*f = map(int, open(0).read().split())
A = f[:X]
B = f[X:X+Y]
C = f[X+Y:]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB = [sum(x) * (-1) for x in product(A,B)]
heapify(AB)
AB_picked = []
for i in range(K):
    if AB:
        AB_picked.append(heappop(AB)*(-1))
    else:
        break
ABC = [sum(x) * (-1) for x in product(AB_picked,C)]
heapify(ABC)
for i in range(K):
    print(heappop(ABC)*(-1))

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

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)]  # multiply -1 to change min to max
    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()

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

    ans = '\n'.join(map(str, num))
    print(ans)


def __starting_point():
    main()

__starting_point()

import heapq
X, Y, Z, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

done = {(0, 0, 0)}

hq = [(-(A[0]+B[0]+C[0]), 0, 0, 0)]
heapq.heapify(hq)  # リストhqのheap化

ans = 0
D = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]

for _ in range(K):
    s, i, j, k = heapq.heappop(hq)  # heap化されたリストhqから最小値を削除＆その最小値を出力
    print((-s))
    for d in D:
        ni, nj, nk = i+d[0], j+d[1], k+d[2]
        if ni < X and nj < Y and nk < Z and (ni, nj, nk) not in done:
            # heap化されたリストhqに要素xを追加
            heapq.heappush(hq, (-(A[ni]+B[nj]+C[nk]), ni, nj, nk))
            done.add((ni, nj, nk))


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


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

    for s, _ in ans:
        print(s)
        

submit()

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:]
    d = []

    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 d:
                    d.append((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()

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

from heapq import heapify, heappop, heappush, heappushpop


class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        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
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])

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, 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 = 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")

import sys
input = sys.stdin.readline
from itertools import product


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):
    # 美味しさの上位K=3000件を出力する
    AB = [a+b for a, b in product(A, B)]
    AB.sort(reverse=True)
    AB = AB[:K]
    C.sort(reverse=True)

    D = [AB[k] + C[0] for k in range(len(AB))]
    E = [0 for k in range(len(AB))]
    j = 0
    for k in range(K):
        hi = 0

        # find
        for i in range(len(D)):
            if D[hi] < D[i]:
                hi = i
        # print
        print((D[hi]))

        # update
        E[hi] += 1
        if E[hi] >= len(C):
            D[hi] = -INF
        else:
            D[hi] = AB[hi] + C[E[hi]]


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

__starting_point()

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

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

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

# D - Cake 123

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)

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)
lst = []

for i in range(len(a)):
    for j in range(len(b)):
        for k in range(len(c)):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            lst.append(a[i] + b[j] + c[k])

new_lst = sorted(lst, reverse = True)
for i in range(K):
    print((new_lst[i]))


import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    import heapq

    X,Y,Z,K = i_map()
    A = i_list()
    B = i_list()
    C = i_list()

    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    Q = []
    heapq.heappush(Q, [-(A[0]+B[0]+C[0]),0,0,0])
    added_idx = set((0,0,0))

    for i in range(K):
        nega_ans, x,y,z = heapq.heappop(Q)
        print(-nega_ans)

        if x+1 < X and (x+1,y,z) not in added_idx:
            heapq.heappush(Q, [-(A[x+1]+B[y]+C[z]),x+1,y,z])
            added_idx.add((x+1,y,z))
        if y+1 < Y and (x,y+1,z) not in added_idx:
            heapq.heappush(Q, [-(A[x]+B[y+1]+C[z]),x,y+1,z])
            added_idx.add((x,y+1,z))
        if z+1 < Z and (x,y,z+1) not in added_idx:
            heapq.heappush(Q, [-(A[x]+B[y]+C[z+1]),x,y,z+1])
            added_idx.add((x,y,z+1))






def __starting_point():
    main()
__starting_point()

import heapq
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()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
al = []

hq = []
heapq.heappush(hq,(-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    hqi,ai,bi,ci = heapq.heappop(hq)
    print((-hqi))
    if ai+1 < x and not (ai+1,bi,ci) in al:
        heapq.heappush(hq,(-(a[ai+1]+b[bi]+c[ci]),ai+1,bi,ci))
        al.append((ai+1,bi,ci))
    if bi+1 < y and not (ai,bi+1,ci) in al:
        heapq.heappush(hq,(-(a[ai]+b[bi+1]+c[ci]),ai,bi+1,ci))
        al.append((ai,bi+1,ci))
    if ci+1 < z and not (ai,bi,ci+1) in al:
        heapq.heappush(hq,(-(a[ai]+b[bi]+c[ci+1]),ai,bi,ci+1))
        al.append((ai,bi,ci+1))


#!/usr/bin/env python3
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()

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)

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

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


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


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


def __starting_point():
    main()

__starting_point()

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)
ans=[]
for i in range(X):
    for j in range(Y):
        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])

# O(klog(k))解法 多分...
import sys
from heapq import heappush,heapify,heappop
input = sys.stdin.readline

def make_kth(A, B, k):
    n, m = len(A), len(B)
    q = [(-A[0] - B[0], 0, 0)]
    r=[]
    for _ in range(min(k, n * m)):
        v, s, t = heappop(q)
        r.append(-v)
        if t + 1 < m:
            heappush(q, (-A[s] - B[t + 1], s, t + 1))
        if t == 0 and s + 1 < n:
            heappush(q, (-A[s + 1] - B[0], s + 1, 0))
    return r

def main():
    _, _, _, 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)

    r = make_kth(a, b, k)
    r = make_kth(c, r, k)
    print(*r, sep="\n")

main()

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


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

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

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

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

#!/usr/bin/env python3
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))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)


def __starting_point():
    main()

__starting_point()

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 = []

# 最大値を取り出していく．
# 以下をK回繰り返す
# 1. -(A+B+C)を要素とするキューの中の最小値を取り出す．(i番目に小さい数) この最小値は(A,B,C)の各リストの(p,q,r)番目のリストに含まれる値．
# 2．このキューに対して(p+1, q, r), (p, q+1, r), (p, q, r+1)のそれぞれが含まれているかどうかを確認
#     ない場合には，キューの管理リストに追加 & キューにその要素を追加
#     ある場合には，特に何もせず．
for i in range(K):
    # キューから最小値を取り出す(負なので実際は最大値を取り出している)
    ans_val, p, q, r = heappop(hq)
    ans_arr.append(-ans_val)
    
    # (p+1, q, r), (p, q+1, r), (p, q, r+1)のそれぞれが含まれているかどうかを確認
    arg_a = (p+1, q, r)
    arg_b = (p, q+1, r)
    arg_c = (p, q, r+1)

    # キューの管理リストに対して，上の要素が存在するかどうかの探索と処理
    # a < X-1 は，全要素がキューに入っている場合に，さらに次のインデックスの要素を追加しないようにするための検索条件
    # p+1 用
    if (p < X-1) and (arg_a not in arg_hash):
        # キュー管理リストに(p+1, q, r)のタプルを登録（辞書キーとして）
        arg_hash[arg_a] = 1
        # キューに値を登録
        heappush(hq, (-(a_list[p+1] + b_list[q] + c_list[r]), ) + arg_a)
    # q+1 用
    if (q < Y-1) and (arg_b not in arg_hash):
        # キュー管理リストに(p+1, q, r)のタプルを登録（辞書キーとして）
        arg_hash[arg_b] = 1
        # キューに値を登録
        heappush(hq, (-(a_list[p] + b_list[q+1] + c_list[r]), ) + arg_b)
    # r+1 用
    if (r < Z-1) and (arg_c not in arg_hash):
        # キュー管理リストに(p+1, q, r)のタプルを登録（辞書キーとして）
        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]))


from heapq import *  # 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 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


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

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)]  # multiply -1 to change min to max
    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()

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)

h = []
a = a_list[0]
b = b_list[0]
c = c_list[0]
heappush(h, (-(a + b + c), 0, 0, 0))

key_dict = dict()
key_dict[(0, 0, 0)] = 1

ans_list = []
for i in range(K):
    ans, a, b, c = heappop(h)
    ans_list.append(-ans)
    a1 = (a + 1, b, c)
    b1 = (a, b + 1, c)
    c1 = (a, b, c + 1)
    if a + 1 < X and not a1 in key_dict:
        heappush(h, (-(a_list[a + 1] + b_list[b] + c_list[c]), a + 1, b, c))
        key_dict[(a + 1, b, c)] = 1
    if b + 1 < Y and not b1 in key_dict:
        heappush(h, (-(a_list[a] + b_list[b + 1] + c_list[c]), a, b + 1, c))
        key_dict[(a, b + 1, c)] = 1
    if c + 1 < Z and not c1 in key_dict:
        heappush(h, (-(a_list[a] + b_list[b] + c_list[c + 1]), a, b, c + 1))
        key_dict[(a, b, c + 1)] = 1
for ans in ans_list:
    print(ans)


# D - Cake 123

import heapq
import itertools
from collections import defaultdict

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 = []
hqAns = []
d = defaultdict(int)

heapq.heappush(hq, ((A[0]+B[0]+C[0])*-1,(0,0,0)))
d[(0,0,0)] = 1

while len(hqAns)<k :
    val, key = heapq.heappop(hq)
    heapq.heappush(hqAns, val)
 
    if d[(key[0]+1, key[1], key[2])]==0 and key[0]+1 < x:
        heapq.heappush(hq, ((A[key[0]+1]+B[key[1]]+C[key[2]])*-1, ((key[0]+1, key[1], key[2]))))
        d[(key[0]+1, key[1], key[2])] = 1

    if d[(key[0], key[1]+1, key[2])]==0 and key[1]+1 < y:
        heapq.heappush(hq, ((A[key[0]]+B[key[1]+1]+C[key[2]])*-1, ((key[0], key[1]+1, key[2]))))
        d[(key[0], key[1]+1, key[2])] = 1
 
    if d[(key[0], key[1], key[2]+1)]==0 and key[2]+1 < z:
        heapq.heappush(hq, ((A[key[0]]+B[key[1]]+C[key[2]+1])*-1, ((key[0], key[1], key[2]+1))))
        d[(key[0], key[1], key[2]+1)] = 1

for i in range(k):
    print((heapq.heappop(hqAns)*-1))

'''
# ans.2 #

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)

'''

'''

# ans.1 #

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

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

import heapq
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()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
al = []

hq = []
heapq.heappush(hq,(-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    hqi,ai,bi,ci = heapq.heappop(hq)
    print((-hqi))
    if ai+1 < x and not (ai+1,bi,ci) in al:
        heapq.heappush(hq,(-(a[ai+1]+b[bi]+c[ci]),ai+1,bi,ci))
        al.append((ai+1,bi,ci))
    if bi+1 < y and not (ai,bi+1,ci) in al:
        heapq.heappush(hq,(-(a[ai]+b[bi+1]+c[ci]),ai,bi+1,ci))
        al.append((ai,bi+1,ci))
    if ci+1 < z and not (ai,bi,ci+1) in al:
        heapq.heappush(hq,(-(a[ai]+b[bi]+c[ci+1]),ai,bi,ci+1))
        al.append((ai,bi,ci+1))


from heapq import *
x,y,z,k = map(int,input().split())
A,B,C = [list(map(int,input().split())) for n in range(3)]
D = nlargest(k,(a+b for a in A for b in B))
E = nlargest(k,(d+c for d in D for c in C))
print("\n".join(map(str,E)))

"""
priority-queue
"""
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])   
#ret=[] 
for i in range(rank):
    poped=queue.pop(0)
    #print(str(i+1)+":"+str(poped[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][poped[j+1]]+lists[j][to_append[j+1]]
            if len(queue)==0:
                queue.append(to_append)  
                continue
            Done=True
            for k in range(len(queue)):
                #print("to cmp")
                #print(queue[k],to_append)
                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
            #print(Done)    
            if Done==True:
                queue.append(to_append)    
            #print("print Queue")
            #for k in range(len(queue)):
            #    print(queue[k])
    if len(queue)>rank-i:
        queue=queue[:(rank-i-1)]
        #print("cut")
    #print("print Queue")    
    #for j in range(len(queue)):
    #            print(queue[j])    




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)

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

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


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


from heapq import heappop, heappush

x, y, z, k = [int(i) for i in input().split()]

a_list = sorted([-int(i) for i in input().split()])
b_list = sorted([-int(i) for i in input().split()])
c_list = sorted([-int(i) for i in input().split()])

hq = []
flag_set = set()

heappush(hq, (a_list[0] + b_list[0] + c_list[0], 0, 0, 0))
flag_set.add((0, 0, 0))
for _ in range(k):
    d, ai, bi, ci = heappop(hq)
    print(-d)
    
    temp = (ai + 1, bi, ci)
    if temp[0] < x and temp not in flag_set:
        heappush(hq, (a_list[ai + 1] + b_list[bi] + c_list[ci], ai + 1, bi, ci))
        flag_set.add(temp)
    
    temp = (ai, bi + 1, ci)
    if temp[1] < y and temp not in flag_set:
        heappush(hq, (a_list[ai] + b_list[bi + 1] + c_list[ci], ai, bi + 1, ci))
        flag_set.add(temp)

    temp = (ai, bi, ci + 1)
    if temp[2] < z and temp not in flag_set:
        heappush(hq, (a_list[ai] + b_list[bi] + c_list[ci + 1], ai, bi, ci + 1))
        flag_set.add(temp)

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