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

ABlist = []

ABClist = []



for x in A:

    for y in B:

        sumple = x + y

        ABlist.append(sumple)

    ABlist.sort(reverse=True)

    ABlist = ABlist[:K]



for x in ABlist:

    for z in C:

        test = x + z

        ABClist.append(test)

    ABClist.sort(reverse=True)

    ABClist = ABClist[:K]



for x in ABClist:

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



heap = []

item = (0,(0,0,0))

max_score = A[0] + B[0] + C[0]

xyzset = set(item[1])

answer = []



heapq.heappush(heap,item)



while len(answer) < K:

    score,(x,y,z) = heapq.heappop(heap)

    answer.append(max_score - score)



    if x != X-1 and (x+1,y,z) not in xyzset:

        heapq.heappush(heap,(max_score - A[x+1] - B[y] - C[z],(x+1,y,z)))

        xyzset.add((x+1,y,z))



    if y != Y-1 and (x,y+1,z) not in xyzset:

        heapq.heappush(heap,(max_score - A[x] - B[y+1] - C[z],(x,y+1,z)))

        xyzset.add((x,y+1,z))



    if z != Z-1 and (x,y,z+1) not in xyzset:

        heapq.heappush(heap,(max_score - A[x] - B[y] - C[z+1],(x,y,z+1)))

        xyzset.add((x,y,z+1))

    

for x in answer:

    print(x)
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()))
ABlist = []
ABClist = []
for x in A:
    for y in B:
        sumple = x + y
        ABlist.append(sumple)
    ABlist.sort(reverse=True)
    ABlist = ABlist[:K]
for x in ABlist:
    for z in C:
        test = x + z
        ABClist.append(test)
    ABClist.sort(reverse=True)
    ABClist = ABClist[:K]
for x in ABClist:
    print(x)

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)
heap = []
item = (0, (0, 0, 0))
max_score = A[0] + B[0] + C[0]
xyzset = set(item[1])
answer = []
heapq.heappush(heap, item)
while len(answer) < K:
    score, (x, y, z) = heapq.heappop(heap)
    answer.append(max_score - score)
    if x != X - 1 and (x + 1, y, z) not in xyzset:
        heapq.heappush(heap, (max_score - A[x + 1] - B[y] - C[z], (x + 1, y, z)))
        xyzset.add((x + 1, y, z))
    if y != Y - 1 and (x, y + 1, z) not in xyzset:
        heapq.heappush(heap, (max_score - A[x] - B[y + 1] - C[z], (x, y + 1, z)))
        xyzset.add((x, y + 1, z))
    if z != Z - 1 and (x, y, z + 1) not in xyzset:
        heapq.heappush(heap, (max_score - A[x] - B[y] - C[z + 1], (x, y, z + 1)))
        xyzset.add((x, y, z + 1))
for x in answer:
    print(x)

+import heapq + -ABlist = [] -ABClist = [] -for x in A: -    for y in B: -        sumple = x + y -        ABlist.append(sumple) -    ABlist.sort(reverse=True) -    ABlist = ABlist[:K] -for x in ABlist: -    for z in C: -        test = x + z -        ABClist.append(test) -    ABClist.sort(reverse=True) -    ABClist = ABClist[:K] -for x in ABClist: +A.sort(reverse=True) +B.sort(reverse=True) +C.sort(reverse=True) +heap = [] +item = (0, (0, 0, 0)) +max_score = A[0] + B[0] + C[0] +xyzset = set(item[1]) +answer = [] +heapq.heappush(heap, item) +while len(answer) < K: +    score, (x, y, z) = heapq.heappop(heap) +    answer.append(max_score - score) +    if x != X - 1 and (x + 1, y, z) not in xyzset: +        heapq.heappush(heap, (max_score - A[x + 1] - B[y] - C[z], (x + 1, y, z))) +        xyzset.add((x + 1, y, z)) +    if y != Y - 1 and (x, y + 1, z) not in xyzset: +        heapq.heappush(heap, (max_score - A[x] - B[y + 1] - C[z], (x, y + 1, z))) +        xyzset.add((x, y + 1, z)) +    if z != Z - 1 and (x, y, z + 1) not in xyzset: +        heapq.heappush(heap, (max_score - A[x] - B[y] - C[z + 1], (x, y, z + 1))) +        xyzset.add((x, y, z + 1)) +for x in answer: