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

res = []
for a in range(X):
    for b in range(Y):
            res.append(A[a] + B[b])
            
res.sort(reverse=True)
result = []
for r in res:
    for c in C:
        result.append(r + c)
        
result.sort(reverse=True)

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

C.sort(reverse=True)

tmp = []
for x in range(X):
    for y in range(Y):
        tmp.append(A[x] + B[y])
        
tmp.sort(reverse=True)

res = []
for i in range(min(K, X*Y)):
    for z in range(Z):
        res.append(tmp[i] + C[z])
 
res.sort(reverse=True)
for i in range(K):
    print((res[i]))
# Original solution
import itertools as it

X, Y, Z, K = [int(n) for n in input().strip().split(' ')]
A = sorted([int(s) for s in input().strip().split(' ')], reverse=True)
B = sorted([int(s) for s in input().strip().split(' ')], reverse=True)
C = sorted([int(s) for s in input().strip().split(' ')], reverse=True)

AB_best = sorted([sum(e) for e in it.product(A, B)], reverse=True)[:K]
best = sorted([sum(e) for e in it.product(AB_best, C)], reverse=True)[:K]
for s in best:
    print(s)


# Optimized solution
X, Y, Z, K = [int(n) for n in input().strip().split(' ')]
A = sorted([int(s) for s in input().strip().split(' ')], reverse=True)
B = sorted([int(s) for s in input().strip().split(' ')], reverse=True)
C = sorted([int(s) for s in input().strip().split(' ')], reverse=True)

ABC = []
for i, a in enumerate(A):
    for j, b in enumerate(B):
        if (i + 1) * (j + 1) > K:
            break

        for k, c in enumerate(C):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break

            ABC.append(a + b + c)

ABC.sort(reverse=True)

for s in ABC[:K]:
    print(s)
# Original solution
x, y, z, k = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
ab = []
for i in a:
    for j in b:
        ab.append(i+j)
ab.sort(reverse = True)
abc = []
k_1 = min([len(ab), k])
for i in ab:
    for j in c:
        abc.append(i+j)
abc.sort(reverse = True)
for i in range(k):
    print((abc[i]))

# Optimized solution
x, y, z, k = list(map(int, input().split(' ')))
a = 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)
abc = []
ab = ab[:k+1]
k_1 = min([len(ab), k])
for i in ab:
    for j in c:
        abc.append(i+j)
abc.sort(reverse = True)
for i in range(k):
    print((abc[i]))
# Original solution
import heapq
import sys
x, y, z, k = list(map(int, input().split()))

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = [[[0 for _ in range(z)] for __ in range(y)] for ___ in range(x)]

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and abc[n+1][m][l]==0:
        abc[n+1][m][l]=1
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and abc[n][m+1][l]==0:
        abc[n][m+1][l]=1
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and abc[n][m][l+1]==0:
        abc[n][m][l+1]=1
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)

# Optimized solution
import heapq
import sys
x, y, z, k = list(map(int, input().split()))

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = {(0,0,0)}

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and not((n+1,m,l) in abc):
        abc.add((n+1,m,l))
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and not((n,m+1,l) in abc):
        abc.add((n,m+1,l))
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and not((n,m,l+1) in abc):
        abc.add((n,m,l+1))
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)
# Original solution
x, y, z, k = list(map(int,input().split()))
alist = [int(i) for i in input().split()]
blist = [int(i) for i in input().split()]
clist = [int(i) for i in input().split()]


# print(x,y,z,k, alist, blist, clist)

#%%
# x,y,z,k,alist,blist,clist = 2, 2, 2, 8, [4, 6],[1, 5],[3, 8]


#%%
alist.sort()
blist.sort()
clist.sort()
alist = alist[::-1][:k]
blist = blist[::-1][:k]
clist = clist[::-1][:k]

#%%
import itertools




#%%
ans = []
for i in list(itertools.product(alist, blist, clist)):
    ans.append((sum(i)))

ans.sort()
#%%
for i in ans[::-1][:k]:
    print(i)

#%%


# Optimized solution
# https://atcoder.jp/contests/abc123/tasks/abc123_d

def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))

X, Y, Z, K = MAP()
A = LIST()
B = LIST()
C = LIST()

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

E = []
for a in A:
    for b in B:
        E.append(a+b)
# E.sort(reverse=True)

ans = []

for c in C:
    for e in E:
        ans.append(c+e)
ans.sort(reverse=True)

for i, a in enumerate(ans):
    if i < K:
        print(a)
    else:
        break
# Original solution
from heapq import heappush, heappop

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)

cake_heap = []
for i in range(len(A)):
    if i + 1 > K:
        break
    for j in range(len(B)):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(len(C)):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            heappush(cake_heap, -(A[i] + B[j] + C[k]))
for i in range(K):
    print((-heappop(cake_heap)))


# Optimized solution
from heapq import heappush, heappop

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)

h = []
minus_value = -(A[0] + B[0] + C[0])
heappush(h, (minus_value, 0, 0, 0))
searched = set()
cnt = 0
while cnt < K:
    minus_value, ia, ib, ic = heappop(h)
    if (ia, ib, ic) in searched:
        continue
    cnt += 1
    searched.add((ia, ib, ic))
    print((-minus_value))
    if ia < X - 1:
        heappush(h, (minus_value + A[ia] - A[ia + 1], ia + 1, ib, ic))
    if ib < Y - 1:
        heappush(h, (minus_value + B[ib] - B[ib + 1], ia, ib + 1, ic))
    if ic < Z - 1:
        heappush(h, (minus_value + C[ic] - C[ic + 1], ia, ib, ic + 1))
# Original solution
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

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

AB.sort(reverse = True)
AB = AB[:K]

ABC = []

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

ABC.sort(reverse = True)

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


# Optimized solution
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = [0] *(len(A) * len(B))
for i in range(len(A)) :
    for j in range(len(B)) :
        AB[len(B) * i + j] = A[i] + B[j]
        
AB.sort(reverse = True)
AB = AB[:K]

ABC = [0] * (len(AB) * len(C))

for i in range(len(AB)) :
    for j in range(len(C)) :
        ABC[len(B) * i + j] = AB[i] + C[j]

ABC.sort(reverse = True)

for i in range(K) :
    print((ABC[i]))
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    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=1)
    B.sort(reverse=1)
    C.sort(reverse=1)
    A=A[:k]
    B=B[:k]
    C=C[:k]
    S=[]
    from itertools import product
    for i,j,l in product(list(range(k)),repeat=3):
        if(i>=x or j>=y or l>=z): continue
        S.append(A[i]+B[j]+C[l])
    S.sort(reverse=1)
    for i in range(k):
        print((S[i]))
resolve()

# Optimized solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    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()))
    S=[]
    T=[]
    from itertools import product
    for a,b in product(A,B):
        S.append(a+b)
    S.sort(reverse=1)
    S=S[:k]
    for s,c in product(S,C):
        T.append(s+c)
    T.sort(reverse=1)
    for i in range(k):
        print((T[i]))
resolve()
# Original solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    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()))
    S=[]
    T=[]
    from itertools import product
    for a,b in product(A,B):
        S.append(a+b)
    S.sort(reverse=1)
    S=S[:k]
    for s,c in product(S,C):
        T.append(s+c)
    T.sort(reverse=1)
    for i in range(k):
        print((T[i]))
resolve()

# Optimized solution
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    x,y,z,K=list(map(int,input().split()))
    A=sorted(map(int,input().split()),reverse=1)
    B=sorted(map(int,input().split()),reverse=1)
    C=sorted(map(int,input().split()),reverse=1)

    # 1<=i<=x,1<=j<=y,1<=k<=z のうち、ijk<=Kを全て取得する
    from itertools import product
    ind=[]
    for i in range(1,x+1):
        if(i>K): break
        for j in range(1,y+1):
            if(i*j>K): break
            for k in range(1,z+1):
                if(i*j*k>K): break
                ind.append((i-1,j-1,k-1))

    S=[]
    for i,j,k in ind:
        S.append(A[i]+B[j]+C[k])
    S.sort(reverse=1)
    for i in range(K):
        print((S[i]))

resolve()
# Original solution
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()
B.sort()
C.sort()

queue = [(A[0]+B[0]+C[0], 0, 0, 0)]
flg = [[[0 for i in range(Z)] for j in range(Y)] for k in range(X)]
flg[0][0][0] = 1

for i in range(K):
    cake, a, b, c = heapq.heappop(queue)
    print((-cake))
    for j in range(3):
        aa = a + [1, 0, 0][j]
        bb = b + [0, 1, 0][j]
        cc = c + [0, 0, 1][j]
        if aa < X and bb < Y and cc < Z:
            if flg[aa][bb][cc] == 0:
                flg[aa][bb][cc] = 1
                heapq.heappush(queue, (A[aa]+B[bb]+C[cc], aa, bb, cc))


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

queue = [(A[0]+B[0]+C[0], 0, 0, 0)]
flg = {}
for i in range(K):
    cake, a, b, c = heapq.heappop(queue)
    print((-cake))
    for j in range(3):
        aa = a + [1, 0, 0][j]
        bb = b + [0, 1, 0][j]
        cc = c + [0, 0, 1][j]
        if aa < X and bb < Y and cc < Z:
            if flg.get((aa, bb, cc)) is None:
                flg[aa, bb, cc] = 1
                heapq.heappush(queue, (A[aa]+B[bb]+C[cc], aa, bb, cc))
# Original solution
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()]

AB = sorted([a + b for a in A for b in B], reverse=True)[:K]
ABC = sorted([ab + c for ab in AB for c in C], reverse=True)[:K]
for a in ABC:
    print(a)


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

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

for b in sorted(a, reverse=True)[:K]:
    print(b)
# Original solution
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)

h = []
heapq.heappush(h, (-(A[0] + B[0] + C[0]), (0, 0, 0)))

ans = []
for _ in range(K):
    p, v = heapq.heappop(h)
    i, j, k = v
    ans.append(p)
    if i + 1 < X and j < Y and k < Z and not (-(A[i+1] + B[j] + C[k]), (i+1, j, k)) in h:
        heapq.heappush(h, (-(A[i + 1] + B[j] + C[k]), (i+1, j, k)))
    if i < X and j + 1 < Y and k < Z and not (-(A[i] + B[j+1] + C[k]), (i, j+1, k)) in h:
        heapq.heappush(h, (-(A[i] + B[j+1] + C[k]), (i, j+1, k)))
    if i < X and j < Y and k + 1 < Z and not (-(A[i] + B[j] + C[k+1]), (i, j, k+1)) in h:
        heapq.heappush(h, (-(A[i] + B[j] + C[k+1]), (i, j, k+1)))

for a in ans:
    print((-a))

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

h = []
heapq.heappush(h, (-(A[0] + B[0] + C[0]), (0, 0, 0)))

ans = []
e = set()
for _ in range(K):
    p, v = heapq.heappop(h)
    i, j, k = v
    ans.append(p)
    if i + 1 < X and j < Y and k < Z and not (-(A[i+1] + B[j] + C[k]), (i+1, j, k)) in e:
        heapq.heappush(h, (-(A[i + 1] + B[j] + C[k]), (i+1, j, k)))
        e.add((-(A[i + 1] + B[j] + C[k]), (i+1, j, k)))
    if i < X and j + 1 < Y and k < Z and not (-(A[i] + B[j+1] + C[k]), (i, j+1, k)) in e:
        heapq.heappush(h, (-(A[i] + B[j+1] + C[k]), (i, j+1, k)))
        e.add((-(A[i] + B[j+1] + C[k]), (i, j+1, k)))
    if i < X and j < Y and k + 1 < Z and not (-(A[i] + B[j] + C[k+1]), (i, j, k+1)) in e:
        heapq.heappush(h, (-(A[i] + B[j] + C[k+1]), (i, j, k+1)))
        e.add((-(A[i] + B[j] + C[k+1]), (i, j, k+1)))

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

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

sums = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                sums.append(A[i]+B[j]+C[k])

list.sort(sums, reverse=True)
for i in range(K):
    print((sums[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(' ')))

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

sums = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            sums.append(A[i]+B[j]+C[k])

for a in sorted(sums, reverse=True)[:K]:
    print(a)
# Original solution
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)
  A += [-1e10]
  B += [-1e10]
  C += [-1e10]

  memo = [A[i] + B[0] + C[0] for i in range(X + 1)]
  L = [[0 for i in range(Y + 1)] for j in range(X + 1)]

  for i in range(K):
    ma = 0
    for j in range(X):
      if memo[ma] < memo[j]:
        ma = j
    print((memo[ma]))
    mb = 0
    mn = 0
    for j in range(Y):
      x = B[j] + C[L[ma][j]]
      if mb < x:
        mb = x
        mn = j
    L[ma][mn] += 1
    n = 0
    for j in range(Y):
      n = max(n, B[j] + C[L[ma][j]])
    memo[ma] = A[ma] + n
 
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()))

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
abc = []
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
      abc.append(A[i] + B[j] + C[k])
    
abc.sort(reverse = True)
for i in range(K):
  print((abc[i]))
# Original solution
import itertools

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

comb_ab = []
for a, b in itertools.product(A, B):
    comb_ab.append(sum([a, b]))

comb_ab_top = sorted(comb_ab, reverse=True)[:K]

comb_abc = []
for ab, c in itertools.product(comb_ab_top, C):
    comb_abc.append(sum([ab, c]))

ans = sorted(comb_abc, reverse=True)[:K]
print(*ans, sep='\n')


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

comb = []
for a in range(X):
    b_max = K // (a+1)
    for b in range(min(Y, b_max)):
        c_max = K // ((a+1)*(b+1))
        for c in range(min(Z, c_max)):
            comb.append(sum([A[a], B[b], C[c]]))

comb.sort(reverse=True)

print(*comb[:K], sep='\n')
# Original solution
from collections import OrderedDict
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)

max_b = max(B)
max_c = max(C)

summs_ab = []
summs = []
for a in A:
    for b in B:
        summs_ab.append(a+b)
summs_ab.sort(reverse=True)
summs_ab = summs_ab[0:min(3001, X*Y*Z+1)]

for c in C:
    for sab in summs_ab:
        summs.append(sab+c)
summs.sort(reverse=True)

for s in summs[0:K]:
    print(s)

# Optimized solution
from collections import OrderedDict
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)

"""
max_b = max(B)
max_c = max(C)
"""

summs_ab = []
summs = []
for a in A:
    for b in B:
        summs_ab.append(a+b)
summs_ab.sort(reverse=True)
summs_ab = summs_ab[0:min(3001, X*Y*Z+1)]

for c in C:
    for sab in summs_ab:
        summs.append(sab+c)
summs.sort(reverse=True)
"""
for a in A[:K]:
    if len(summs) >= K and a + max_b + max_c < summs[K-1]:
        break

    for b in B[:K]:
        if len(summs) >= K and a + b + max_c < summs[K-1]:
            break

        for c in C[:K]:
            summ = a + b + c
            if len(summs) >= K:
                min_sum = summs[K-1]    
                if summ < min_sum:
                    break
            summs.append(summ)
        summs = merge_sort(summs)
        summs.reverse()
"""
for i in range(K):
    print((summs[i]))
# Original solution
x,y,z,k = list(map(int,input().split()))
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print((ans[i]))


# Optimized solution
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

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

result = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                result.append(A[i] + B[j] + C[k])
            else:
                break
result.sort(reverse=True)
for rs in result[:K]:
    print(rs)
# Original solution
x,y,z,k=list(map(int,input().split()))
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
a=1
b=1
c=1
A.append(-10**11)
B.append(-10**11)
C.append(-10**11)
A.insert(0,-10**11)
B.insert(0,-10**11)
C.insert(0,-10**11)
print((A[a]+B[b]+C[c]))

memo=[[[False]*(z+2) for _ in range(y+2)] for _ in range(x+2)]
memo[a][b][c]=True

for _ in range(k-1):
    keepv=0
    for a2 in range(1,x+2):
        for b2 in range(1,y+2):
            for c2 in range(1,z+2):
                if not memo[a2][b2][c2]:
                    if A[a2]+B[b2]+C[c2]>keepv:
                        keepv=A[a2]+B[b2]+C[c2]
                        keepa=a2
                        keepb=b2
                        keepc=c2
    a=keepa
    b=keepb
    c=keepc
    print((A[a]+B[b]+C[c]))
    #print(a,b,c)
    #print(memo[2][1][1])
    memo[a][b][c]=True

# 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)
AB=sorted(AB,reverse=True)[:k]
ABC=[]
for ab in AB:
    for c in C:
        ABC.append(ab+c)
ABC.sort(reverse=True)
for abc in ABC[:k]:
    print(abc)
# Original solution
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

from bisect import bisect_left, bisect_right

def C(x):
    # count "abc <= x"
    ret = 0
    for aa in a:
        for bb in b:
            idx = bisect_right(c, x - aa - bb)
            ret += idx
    return ret

kk = x * y * z - k + 1
lb = 0
ub = (10 ** 10) * 4
while ub - lb > 1:
    mid = (ub + lb) // 2
    if C(mid) >= kk:
        ub = mid
    else:
        lb = mid

kth = ub


l = []
for aa in a:
    for bb in b:
        idx = bisect_left(c, kth - aa - bb)
        # print(aa, bb, idx)
        for i in range(idx, z):
            l.append(aa + bb + c[i])


l.sort(reverse=True)
for ll in l:
    print(ll)


# Optimized solution


if __name__ == '__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()))

    bc = []
    for bb in b:
        for cc in c:
            bc.append(bb + cc)
    bc.sort()

    from bisect import bisect_left

    def C(x):
        # count "abc >= x"
        ret = 0
        for aa in a:
            idx = bisect_left(bc, x - aa)
            ret += len(bc) - idx
        return ret

    lb = 0
    ub = (10 ** 10) * 3 + 1
    while ub - lb > 1:
        mid = (ub + lb) // 2
        if C(mid) >= k:
            lb = mid
        else:
            ub = mid

    kth = lb

    l = []
    for aa in a:
        idx = bisect_left(bc, kth - aa)
        for i in range(idx, len(bc)):
            l.append(aa + bc[i])

    l.sort(reverse=True)
    l = l[:k]
    for ll in l:
        print(ll)