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


A = sorted(A, key = lambda x:-x)
B = sorted(B, key = lambda x:-x)
C = sorted(C, key = lambda x:-x)

AB = [0] * (X * Y)

index = 0
for i in range(len(A)):
    for j in range(len(B)):
        AB[index] = A[i] + B[j]
        index += 1

AB = sorted(AB, key = lambda x:-x)
AB = AB[0:3010]

ABC = [0] * (3010 * Z)
index = 0

for i in AB:
    for j in range(len(C)):
        if j > 3010:
            break
        ABC[index] = i + C[j]
        index += 1

ABC = sorted(ABC, key = lambda x:-x)
for i in range(0,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())) 


A = sorted(A, key = lambda x:-x)
B = sorted(B, key = lambda x:-x)
C = sorted(C, key = lambda x:-x)

AB = [0] * (X * Y)

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 = sorted(ABC, key = lambda x:-x)
for i in range(0, K):
    print((ABC[i]))
# Original solution
X,Y,Z,K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A,reverse=True)
B = sorted(B,reverse=True)
C = sorted(C,reverse=True)
#print(A,B,C)

list1 = []
a,b,c = 0,0,0

for a in range(X):
  for b in range(Y):
    for c in range(Z):
      list1.append(A[a]+B[b]+C[c])

for i in range(K):
  print((max(list1)))
  list1.remove(max(list1))

# 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] * (X * Y)
for i in range(X):
  for j in range(Y):
    AB[i * Y + j] = A[i] + B[j]

AB = sorted(AB, reverse = True)[:K]
#print(AB)
ABC = []
for i in range(len(AB)):
  for j in range(Z):
    ABC.append(AB[i] + C[j])
    
ABC = sorted(ABC, reverse = True)[:K]

for i in range(K):
  print((ABC[i]))
# Original solution
x,y,z,k=list(map(int, input().split()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
import itertools
combi=list(itertools.product(a,b,c))
ans=[0]*len(combi)
for i in range(len(combi)):
    ans[i]= sum(combi[i])
ans.sort(reverse=True)
for x in ans[:k]:
    print(x)

# 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()))
import itertools
combi=list(itertools.product(a,b))
ans=[0]*len(combi)
for i in range(len(combi)):
    ans[i]= sum(combi[i])
ans.sort(reverse=True)
combi2=list(itertools.product(ans[:k],c))
ans2=[0]*len(combi2)
for j in range(len(combi2)):
    ans2[j]=sum(combi2[j ])
ans2.sort(reverse=True)
for x in ans2[:k]:
    print(x)
# Original solution
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
L = []
for i in A:
  for j in B:
    L.append(i+j)
S = sorted(L, reverse=True)[:k]
T = []
for i in S:
  for j in sorted(C, reverse=True)[:k]:
    T.append(i+j)
print(*sorted(T, reverse=True)[:k], 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)
L = []
for i in range(min(x, k)):
  for j in range(min(y, k//(i+1))):
    for l in range(min(z, k//(i+1)//(j+1))):
      L.append(A[i]+B[j]+C[l])
print(*sorted(L)[::-1][:k], sep="\n")
# Original solution
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
L = []
for a in A:
  for b in B:
    L.append(a + b)
L.sort(reverse = True)
ans = []
for i, l in enumerate(L):
  if i == K:
    break
  else:
    for c in C:
      ans.append(l + c)
ans.sort(reverse = True)
for i, a in enumerate(ans):
  if i == K:
    break
  else:
    print(a)


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

L = []
for i, a in enumerate(A):
  for j, b in enumerate(B):
    if i * j > K:
      continue
    else:
      L.append(a + b)

L.sort(reverse = True)
ans = []
for i, l in enumerate(L):
  if i == K:
    break
  else:
    for c in C:
      ans.append(l + c)
ans.sort(reverse = True)
for i, a in enumerate(ans):
  if i == K:
    break
  else:
    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()))

ABC = []
for a in A:
    for b in B:
        for c in C:
            ABC.append(a+b+c)
ABC = sorted(ABC,reverse=True)
for k in range(K):
    print((ABC[k]))


        

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

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

for c in C:
    for ab in AB:
        ABC.append(c + ab)
ABC = sorted(ABC,reverse=True)        
print(*ABC[:K],sep="\n")
# Original solution
# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d

"""
import sys


from itertools import product

def solve(X, Y, Z, K, A, B, C):
    res_AB = sorted([sum(p) for p in product(A, B)], reverse=True)[:K]
    return sorted([sum(p) for p in product(res_AB, C)], reverse=True)[:K]


def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


# Optimized solution
# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d

"""
import sys


from itertools import product

def solve(X, Y, Z, K, A, B, C):
    # TLE
    res_AB = sorted([sum(p) for p in product(A, B)], reverse=True)[:K]
    return sorted([sum(p) for p in product(res_AB, C)], reverse=True)[:K]


def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])
# Original solution
# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d
AC
"""
import sys


from itertools import product

def solve(X, Y, Z, K, A, B, C):
    # 解説の解法#2
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    res = []
    for i, a in enumerate(A, start=1):
        for j, b in enumerate(B, start=1):
            for k, c in enumerate(C, start=1):
                if i*j*k > K:
                    break
                res.append(a+b+c)
    return sorted(res, reverse=True)[:K]


def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


# Optimized solution
# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d
AC
"""
import sys

def solve(X, Y, Z, K, A, B, C):
    # 解説の解法#2
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    res = []
    for i, a in enumerate(A, start=1):
        for j, b in enumerate(B, start=1):
            for k, c in enumerate(C, start=1):
                if i*j*k > K:
                    break
                res.append(a+b+c)
    return sorted(res, reverse=True)[:K]


def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])
# Original solution
x,y,z,k=list(map(int,input().split()))
al=[int(i) for i in input().split()]
bl=[int(i) for i in input().split()]
cl=[int(i) for i in input().split()]
lst=[i+j for i in al for j in bl]
lst.sort(reverse=True)
num=min(x*y,k)
lst=lst[:num]
L=[i+j for i in cl for j in lst]
L.sort(reverse=True)
for i in range(k):
  print((L[i]))

# Optimized solution
def main():
  x,y,z,k=list(map(int,input().split()))
  al=[int(i) for i in input().split()]
  bl=[int(i) for i in input().split()]
  cl=[int(i) for i in input().split()]
  lst=[i+j for i in al for j in bl]
  lst.sort(reverse=True)
  num=min(x*y,k)
  lst=lst[:num]
  L=[i+j for i in cl for j in lst]
  L.sort(reverse=True)
  for i in range(k):
    print((L[i]))
if __name__=='__main__':
  main()
# 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()]

a.sort(reverse=True),b.sort(reverse=True),c.sort(reverse=True)
ab = []
for i in range(x):
  for j in range(y):
    ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab = ab[0:k]
abc = []
for i in ab:
  for j in c:
    abc.append(i+j)
abc.sort(reverse=True)
abc = abc[0:k]
for i in abc:
  print(i)

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

a.sort(reverse=True),b.sort(reverse=True),c.sort(reverse=True)
abc = []

for i in range(x):
  
  for j in range(y):
   
    for l in range(z):
      if (i+1)*(j+1)*(l+1)>k:
        break
      abc.append(a[i]+b[j]+c[l])
abc.sort(reverse=True)
abc = abc[0:k]
for i in abc:
  print(i)
# Original solution
import itertools
import sys

input = sys.stdin.readline

maxn = 10000000000

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.append(-maxn)
B.append(-maxn)
C.append(-maxn)

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

apos, bpos, cpos = 0, 0, 0

while (apos + 1) * (bpos + 1) * (cpos + 1) < min(2 * 10 ** 6, X * Y * Z):
    if (
        apos < len(A) - 2
        and abs(A[apos] - A[apos + 1]) < abs(B[bpos] - B[bpos + 1])
        and abs(A[apos] - A[apos + 1]) < abs(C[cpos] - C[cpos + 1])
    ):
        apos += 1
    elif bpos < len(B) - 2 and B[bpos] - B[bpos + 1] < C[cpos] - C[cpos + 1]:
        bpos += 1
    else:
        cpos += 1

res = []
for a in list(itertools.product(A[: apos + 1], B[: bpos + 1], C[: cpos + 1])):
    res.append(a[0] + a[1] + a[2])

res.sort(reverse=True)
for k in range(K):
    print((res[k]))


# Optimized solution
import itertools
import sys

input = sys.stdin.readline

maxn = 10000000000

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)

cand = []
for i, a in enumerate(A):
    for j, b in enumerate(B):
        for k, c in enumerate(C):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                cand.append(a + b + c)
            else:
                break

cand.sort(reverse=True)
for k in range(K):
    print((cand[k]))
# Original solution
x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
alist.sort(reverse=True)
blist.sort(reverse=True)
clist.sort(reverse=True)
delist = []
for a in range(x) :
    for b in range(y) :
        if a+b > k :
            break
        for c in range(z) :
            if a+b+c > k :
                break
            else :
                delist.append(alist[a]+blist[b]+clist[c])
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)

# Optimized solution
x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
alist.sort(reverse=True)
blist.sort(reverse=True)
clist.sort(reverse=True)
delist = []
for a in range(x) :
    for b in range(y) :
        if a*b > k :
            break
        for c in range(z) :
            if a*b*c > k :
                break
            else :
                delist.append(alist[a]+blist[b]+clist[c])
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)
# Original solution
def main():
    X, Y, Z, K = list(map(int, input().split()))
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]

    AB = []
    ABappend = AB.append
    for i in range(X):
        for j in range(Y):
            ABappend(A[i] + B[j])
    ABC = []
    ABCappend = ABC.append
    for i in range(X * Y):
        for j in range(Z):
            ABCappend(AB[i] + C[j])
    ABC.sort(reverse=True)
    print(('\n'.join(map(str, ABC[:K]))))


if __name__ == '__main__':
    main()


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

    AB = []
    ABappend = AB.append
    for i in range(X):
        for j in range(Y):
            ABappend(A[i] + B[j])
    AB.sort(reverse=True)
    ABC = []
    ABCappend = ABC.append
    for i in range(min(K, X*Y)):
        for j in range(Z):
            ABCappend(AB[i] + C[j])
    ABC.sort(reverse=True)
    print(('\n'.join(map(str, ABC[:K]))))


if __name__ == '__main__':
    main()
# Original solution
from itertools import product
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 = [sum(ab) for ab in product(A, B)]
AB.sort(reverse=True)
AB = AB[:k]
ABC = [sum(abc) for abc in product(AB, C)]
ABC.sort(reverse=True)
for i in range(k):
    print((ABC[i]))


# Optimized solution
x, y, z, K = list(map(int, input().split()))
A = sorted(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]))
# Original solution
x, y, z, k = list(map(int, input().split()))
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
Z = [int(i) for i in input().split()]

count = []

for i in X:
    for j in Y:
        for l in Z:
            count.append(i+j+l)

count.sort(reverse=1)

for c in range(k):
    print((count[c]))


# Optimized solution
x, y, z, k = list(map(int, input().split()))
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
Z = [int(i) for i in input().split()]


answer = []
for i in X:
    for j in Y:
        answer.append(i+j)
answer.sort(reverse=1)

answer2 = []
for l in Z[:k]:
    for a in answer[:k]:
        answer2.append(l+a)
answer2.sort(reverse=1)

for p in answer2[:k]:
    print(p)
# Original solution
x, y, z, k = list(map(int, input().split()))
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
Z = [int(i) for i in input().split()]
X.sort(reverse=1)
Y.sort(reverse=1)
Z.sort(reverse=1)

answer = []
for i in X[:k]:
    for j in Y[:k]:
        answer.append(i+j)
answer.sort(reverse=1)

answer2 = []
for l in Z[:k]:
    for a in answer[:k]:
        answer2.append(l+a)
answer2.sort(reverse=1)

for p in answer2[:k]:
    print(p)

# Optimized solution
x, y, z, k = list(map(int, input().split()))
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
Z = [int(i) for i in input().split()]
X.sort(reverse=1)
Y.sort(reverse=1)
Z.sort(reverse=1)

answer = [i+j for i in X[:k] for j in Y[:k]]
answer.sort(reverse=1)

answer2 = [i+j for i in Z[:k] for j in answer[:k]]
answer2.sort(reverse=1)

for p in answer2[:k]:
    print(p)
# Original solution
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
result = []

for c in range(z):
    for b in range(y):
        for a in range(x):
            result.append(A[a] + B[b] + C[c])

result.sort()
[print(val) for val in result[-k:][::-1]]


# Optimized solution
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
result = []

def func1():
    E = [a+b for a in A for b in B]
    E.sort()
    if len(E) > k: E = E[-k:]
    F = [c+e for c in C for e in E]
    F.sort()
    return F[-k:][::-1]

[print(val) for val in func1()]
# Original solution
X,Y,Z,K = list(map(int,input().split()))
K = min(K,X*Y*Z)
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)
sum2 = []
for a in A:
    for b in B:
        sum2.append(a+b)
sum2.sort(reverse = True)
sum2 = sum2[:K]
idx = 0
sum3 = []
for c in C:
    for s in sum2:
        sum3.append(c+s)
sum3.sort(reverse=True)
for i in range(K):
    print((sum3[i]))

# Optimized solution
import heapq
X,Y,Z,K = list(map(int,input().split()))
K = min(K,X*Y*Z)
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)
set_ = set()
hq = [(-(A[0]+B[0]+C[0]),0,0,0)]
heapq.heapify(hq)
set_.add((0,0,0))
while K:
    val,i,j,k = heapq.heappop(hq)
    print((-val))
    K-=1
    if i+1<len(A) and (i+1,j,k) not in set_: 
        heapq.heappush(hq,(-(A[i+1]+B[j]+C[k]),i+1,j,k))
        set_.add((i+1,j,k))
    if j+1<len(B) and (i,j+1,k) not in set_: 
        heapq.heappush(hq,(-(A[i]+B[j+1]+C[k]),i,j+1,k))
        set_.add((i,j+1,k))
    if k+1<len(C) and (i,j,k+1) not in set_: 
        heapq.heappush(hq,(-(A[i]+B[j]+C[k+1]),i,j,k+1))
        set_.add((i,j,k+1))
# Original solution
x,y,z,K = list(map(int, input().split()))
abc = [sorted(list(map(int, input().split())), reverse=True) for i in range(3)]

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(abc[0][i]+abc[1][j]+abc[2][k])
for i in sorted(ans)[::-1][:K]:
    print(i)

# Optimized solution
x,y,z,K = list(map(int, input().split()))
abc = [sorted(list(map(int, input().split())), reverse=True) for i in range(3)]

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(abc[0][i]+abc[1][j]+abc[2][k])
            else:
                break
for i in sorted(ans)[::-1][:K]:
    print(i)
# Original solution
import bisect
a,b,c,k = list(map(int,input().split()))

aa = list(map(int,input().split()))
bb = list(map(int,input().split()))
cc = list(map(int,input().split()))
aa.sort(reverse = True)
bb.sort(reverse = True)
cc.sort(reverse = True)
al = []

for i in range(a):
    for j in range(b):
        for l in range(c):
            kk = aa[i]+bb[j]+cc[l]
            bisect.insort_left(al,kk)
al.reverse()
for i in range(k):
    print((al[i]))

# Optimized solution
a,b,c,k = list(map(int,input().split()))

aa = list(map(int,input().split()))
aa.sort(reverse = True)
bb = list(map(int,input().split()))
bb.sort(reverse = True)
cc = list(map(int,input().split()))
cc.sort(reverse = True)
al = []
aal = []
for i in aa:
    for j in bb:
        al.append(i+j)
al.sort()
if len(al) > k:
    al = al[len(al)-k:]

for i in al:
    for j in cc:
        aal.append(i+j)
aal.sort()

if len(aal) > k:
    aal = aal[len(aal)-k:]
aal.reverse()
for i in aal:
    print(i)
# Original solution
x,y,z,k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
c = sorted(c)
memory = []
ai = x-1
bi = y-1
ci = z-1
p = 10**11
while k>0:
    ps = []
    abc = []
    for dx in range(-8,8):
        for dy in range(-8,8):
            for dz in range(-8,8):
                if not (ai+dx>=0 and ai+dx<x and bi+dy>=0 and bi+dy<y and ci+dz>=0 and ci+dz<z):
                    continue
                tmp = a[ai+dx]+b[bi+dy]+c[ci+dz]
                if p >= tmp and not (ai+dx,bi+dy,ci+dz) in memory:
                    ps.append(tmp) 
                    abc.append((ai+dx, bi+dy, ci+dz))
    p = max(ps)
    i = ps.index(p)
    memory.append(abc[i])
    print(p)
    k -= 1


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

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

    T = sorted(T, reverse=True)[:min(K, len(T))]

    res = []
    for t in T:
        for c in C:
            res.append(t + c)

    res = sorted(res, reverse=True)[:K]
    for r in res:
        print(r)

if __name__ == "__main__":
    main()
# Original solution
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# A.sort(reverse=True)
# B.sort(reverse=True)
# C.sort(reverse=True)
# m = A[0]+B[0]+C[0]
AB = []
for a in A:
    for b in B:
        AB.append(a+b)
ABC = []
for c in C:
    for ab in AB:
        ABC.append(c+ab)
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()))
# A.sort(reverse=True)
# B.sort(reverse=True)
# C.sort(reverse=True)
# m = A[0]+B[0]+C[0]
AB = []
ABC = []
for a in A:
    for b in B:
        AB.append(a+b)
AB.sort(reverse=True)
AB = AB[:K]
for c in C:
    for ab in AB:
        ABC.append(c+ab)
ABC.sort(reverse=True)
for i in range(K):
    print((ABC[i]))
# Original solution
x,y,z,k = [int(num) for num in input().split()]
a_cake,b_cake,c_cake = [sorted([int(num) for num in input().split()],reverse=True)[:k] for _ in range(3)]

sum_cake = sorted([a+b+c for a in a_cake for b in b_cake for c in c_cake],reverse=True)[:k]

for i in sum_cake:
    print(i)




# Optimized solution
x,y,z,k = [int(num) for num in input().split()]
a_cake,b_cake,c_cake = [sorted([int(num) for num in input().split()],reverse=True)[:k] for _ in range(3)]

sum_cake=list()
for i,a in enumerate(a_cake,1):
    for j,b in enumerate(b_cake,1):
        if(i*j>k):
            break
        for n,c in enumerate(c_cake,1):
            if(i*j*n>k):
                break
            sum_cake.append(a+b+c)


sum_cake.sort(reverse=True)

for i in sum_cake[:k]:
    print(i)