CodeEff/ECCO huggingface dataset:
# Original solution
import heapq
import collections

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 = []
heapq.heapify(heap)
heapq.heappush(heap,(-(A[0]+B[0]+C[0]),0,0,0))

dictionary = collections.defaultdict(bool)
dictionary[(0,0,0)] = True

i = 0

while i<k:
    M = heapq.heappop(heap)
    print((-M[0]))
    i += 1
    if not dictionary[(M[1]+1,M[2],M[3])] and M[1]+1<x:
        heapq.heappush(heap,(-(A[M[1]+1]+B[M[2]]+C[M[3]]),M[1]+1,M[2],M[3]))
        dictionary[(M[1]+1,M[2],M[3])] = True
    if not dictionary[(M[1],M[2]+1,M[3])] and M[2]+1<y:
        heapq.heappush(heap,(-(A[M[1]]+B[M[2]+1]+C[M[3]]),M[1],M[2]+1,M[3]))
        dictionary[(M[1],M[2]+1,M[3])] = True
    if not dictionary[(M[1],M[2],M[3]+1)] and M[3]+1<z:
        heapq.heappush(heap,(-(A[M[1]]+B[M[2]]+C[M[3]+1]),M[1],M[2],M[3]+1))
        dictionary[(M[1],M[2],M[3]+1)] = True

# Optimized solution
from heapq import heappop, heappush, heapify

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 = list()
used = set()
res = list()

heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))
used.add((0, 0, 0))

for _ in range(K):
    v, i, j, k = heappop(heap)
    res.append(-v)
    if i + 1 < X and (i + 1, j, k) not in used:
        used.add((i + 1, j, k))
        heappush(heap, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
    if j + 1 < Y and (i, j + 1, k) not in used:
        used.add((i, j + 1, k))
        heappush(heap, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
    if k + 1 < Z and (i, j, k + 1) not in used:
        used.add((i, j, k + 1))
        heappush(heap, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
        
print(('\n'.join(map(str, res))))
# Original solution
def dfs(count, ans, ll):
    if count == 2:
        for cc in c:
            cccc = ans + cc
            if cccc is not None:
                ll.append(cccc)
    if count == 1:
        for bb in b:
            bbbb = dfs(count+1, ans+bb, ll)
            if bbbb is not None:
                ll.append(bbbb)
    if count == 0:
        for aa in a:
            aaaa = dfs(count+1, ans+aa, ll)
            if aaaa is not None:
                ll.append(aaaa)
        return ll

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()]
aaa = []
ans = dfs(0, 0, aaa)
ans.sort()
ans = list(reversed(ans))
for i in range(k):
    print((ans[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 = list(reversed(sorted(a)))
b = list(reversed(sorted(b)))
c = list(reversed(sorted(c)))
ans = []
for i in range(x):
    for j in range(y):
        for l in range(z):
            if i * j * l <= k:
                ans.append(a[i] + b[j] + c[l])
            else:
                break
ans = list(reversed(sorted(ans)))
for i in range(k):
    print((ans[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.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

import heapq
nums=[[-(A[0]+B[0]+C[0]), 0, 0, 0]]
heapq.heapify(nums)

sumi=[[[0]*Z for __ in range(Y)] for _ in range(X)]
for _ in range(K):
  out, a, b, c=heapq.heappop(nums)
  print((-out))
  if a<X-1 and sumi[a+1][b][c]==0:
    heapq.heappush(nums, [-(A[a+1]+B[b]+C[c]), a+1, b, c])
    sumi[a+1][b][c]=1
  if b<Y-1 and sumi[a][b+1][c]==0:
    heapq.heappush(nums, [-(A[a]+B[b+1]+C[c]), a, b+1, c])
    sumi[a][b+1][c]=1
  if c<Z-1 and sumi[a][b][c+1]==0:
    heapq.heappush(nums, [-(A[a]+B[b]+C[c+1]), a, b, c+1])
    sumi[a][b][c+1]=1


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

import heapq
nums=[[-(A[0]+B[0]+C[0]), 0, 0, 0]]
heapq.heapify(nums)

sumi=[[0, 0, 0]]
for _ in range(K):
  out, a, b, c=heapq.heappop(nums)
  print((-out))
  if a<X-1 and not([a+1, b, c] in sumi):
    heapq.heappush(nums, [-(A[a+1]+B[b]+C[c]), a+1, b, c])
    sumi.append([a+1, b, c])
  if b<Y-1 and not([a, b+1, c] in sumi):
    heapq.heappush(nums, [-(A[a]+B[b+1]+C[c]), a, b+1, c])
    sumi.append([a, b+1, c])
  if c<Z-1 and not([a, b, c+1] in sumi):
    heapq.heappush(nums, [-(A[a]+B[b]+C[c+1]), a, b, c+1])
    sumi.append([a, b, c+1])
# Original solution
# coding: utf-8
#解法1 ABのK番まで　＋　CのK番まで
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(min(K,X)):
    for j in range(min(K,Y)):
        AB.append(A[i]+B[j])

AB.sort(reverse=True)
C.sort(reverse=True)

ABC=[]

for i in range(min(K,X*Y)):
    for j in range(min(K,Z)):
        ABC.append(AB[i]+C[j])

ABC.sort(reverse=True)

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


# Optimized solution
# coding: utf-8
#解法1 ABのK番まで　＋　CのK番まで
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):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            else:
                ABC.append(A[i]+B[j]+C[k])
        if (i+1)*(j+1)>K:
            break
    if i+1>K:
        break

ABC.sort(reverse=True)

for i in range(K):
    print((ABC[i]))
# Original solution
# coding: utf-8
#解法1 ABのK番まで　＋　CのK番まで
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):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            else:
                ABC.append(A[i]+B[j]+C[k])
        if (i+1)*(j+1)>K:
            break
    if i+1>K:
        break

ABC.sort(reverse=True)

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


# Optimized solution
# coding: utf-8
#解法2 abc<=Kのみのリスト
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):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            else:
                ABC.append(A[i]+B[j]+C[k])
        if (i+1)*(j+1)>K:
            break
    if i+1>K:
        break

ABC.sort(reverse=True)

for i in range(K):
    print((ABC[i]))
# Original solution
import sys
input = sys.stdin.readline

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

    ans = []
    for a in A:
        for b in B:
            for c in C:
                ans.append(a + b + c)

    ans_s = sorted(ans, reverse=True)

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


if __name__ == '__main__':
    main()



# Optimized solution
import sys
input = sys.stdin.readline

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

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

    ans_s = sorted(ans, reverse=True)

    ans2 = []
    for a in ans_s[:3000]:
        for c in C:
            ans2.append(a + c)

    ans2_s = sorted(ans2, reverse=True)

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


if __name__ == '__main__':
    main()
# Original solution
x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

A = A[::-1]
B = B[::-1]
C = C[::-1]

anslist = []

for i in range(len(A)):
    if i > k:
        break
    for j in range(len(B)):
        if i * j > k:
            break
        for l in range(len(C)):
            if (i + 1) * (j + 1) * (l + 1) > k:
                break
            anslist.append(A[i] + B[j] + C[l])

anslist.sort()

anslist = anslist[::-1]

for i in range(k):
    print((anslist[i]))


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

A = A[::-1]
B = B[::-1]
C = C[::-1]

anslist = []

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 l in range(len(C)):
            if (i + 1) * (j + 1) * (l + 1) > k:
                break
            anslist.append(A[i] + B[j] + C[l])

anslist.sort()

anslist = anslist[::-1]

for i in range(k):
    print((anslist[i]))
# Original solution
# coding: utf-8

import sys
input = sys.stdin.readline

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

bimi = []
for a in range(X):
        for b in range(Y):
                bimi.append(A[a] + B[b])

bimi.sort(reverse=True)
ans = []
for x in range(min(K, len(bimi))):
        for c in range(Z):
                ans.append(bimi[x] + C[c])

ans.sort(reverse=True)

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



# Optimized solution
# coding: utf-8

import sys
input = sys.stdin.readline

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)

bimi = []

for a in range(X):
        for b in range(Y):
                if (a + 1) * (b + 1) > K:
                                break

                for c in range(Z):
                        if (a + 1) * (b + 1) * (c + 1) > K:
                                break

                        bimi.append(A[a] + B[b] + C[c])

bimi.sort(reverse=True)

for i in range(K):
        print((bimi[i]))
# Original solution
x,y,z,n = 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)
d = []
for i,i1 in enumerate(a):
  for j,j1 in enumerate(b):
    for k,k1 in enumerate(c):
      if (i+1) * (j+1) * (k+1) <= n:
        d.append(i1 + j1 + k1)
d.sort(reverse = True)
for i in d[:n]:
  print(i)

# Optimized solution
x,y,z,n = 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)
d = []
for i,i1 in enumerate(a):
  for j,j1 in enumerate(b):
    if (i+1)*(j+1) <= n:
      for k,k1 in enumerate(c):
        if (i+1) * (j+1) * (k+1) <= n:
          d.append(i1 + j1 + k1)
        else:
          break
    else:
      break
d.sort(reverse = True)
for i in d[:n]:
  print(i)
# Original solution
def resolve():
    X, Y, Z, K = list(map(int, input().split()))
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    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 = sorted(ABC, reverse=True)
    [print(ABC[i]) for i in range(K)]


if '__main__' == __name__:
    resolve()


# Optimized solution
def resolve():
    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)

    ABC = []
    for i in range(X):
        for j in range(Y):
            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, reverse=True)
    [print(ABC[i]) for i in range(K)]

if '__main__' == __name__:
    resolve()
# Original solution
import itertools
import heapq
import copy

def inv(l):
    return list([x*-1 for x in l])

def solve(A,B,C, K):
    A,B,C = inv(A), inv(B), inv(C)
    A = sorted(A)
    B = sorted(B)
    C = sorted(C)
    ind = set([(0,0,0)])

    h = [(A[0]+ B[0]+ C[0], (0,0,0))]
    res = []

    for _ in range(K):
        h2 = copy.copy(h)
        for (val, (i,j,k)) in h2:
            if i+1 < len(A) and (i+1,j,k) not in ind:
                heapq.heappush(h, (A[i+1]+B[j]+C[k], (i+1, j, k)))
                ind |= set([(i+1,j,k)])
            if j+1 < len(B) and (i,j+1, k) not in ind:
                heapq.heappush(h, (A[i]+B[j+1]+C[k], (i, j+1, k)))
                ind |= set([(i,j+1,k)])
            if k+1 < len(C) and (i,j, k+1) not in ind:
                heapq.heappush(h, (A[i]+B[j]+C[k+1], (i, j, k+1)))
                ind |= set([(i,j,k+1)])
        res += [heapq.heappop(h)]
    for r in res:
        print((r[0]*-1))

la,lb,lc,K = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

solve(A,B,C,K)

# Optimized solution
import itertools
import heapq
import copy

def inv(l):
    return list([x*-1 for x in l])

def solve(A,B,C, K):
    A,B,C = inv(A), inv(B), inv(C)
    A = sorted(A)
    B = sorted(B)
    C = sorted(C)
    ind = set([(0,0,0)])

    h = [(A[0]+ B[0]+ C[0], (0,0,0))]
    res = []

    for _ in range(K):
        h2 = copy.copy(h)
        val, (i,j,k) = heapq.heappop(h)
        res += [-val]
        if i+1 < len(A) and (i+1,j,k) not in ind:
            heapq.heappush(h, (A[i+1]+B[j]+C[k], (i+1, j, k)))
            ind |= set([(i+1,j,k)])
        if j+1 < len(B) and (i,j+1, k) not in ind:
            heapq.heappush(h, (A[i]+B[j+1]+C[k], (i, j+1, k)))
            ind |= set([(i,j+1,k)])
        if k+1 < len(C) and (i,j, k+1) not in ind:
            heapq.heappush(h, (A[i]+B[j]+C[k+1], (i, j, k+1)))
            ind |= set([(i,j,k+1)])
    for r in res:
        print(r)

la,lb,lc,K = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

solve(A,B,C,K)
# Original solution
# TODO D - Cake 123
# https://atcoder.jp/contests/abc123/tasks/abc123_d

X, Y, Z, K = list(map(int, input().split()))

A = [int(x) for x in input().split()]
B = [int(y) for y in input().split()]
C = [int(z) for z in input().split()]

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

for i in ABC[:K]:
    print('{}'.format(i))


# Optimized solution
#abc123d
 
x,y,z,k=list(map(int,input().split()))
a=sorted(map(int,input().split()),reverse=True)
b=sorted(map(int,input().split()),reverse=True)
c=sorted(map(int,input().split()),reverse=True)
 
ab=sorted([i+j for i in a for j in b],reverse=True)
res=sorted([ij+l for ij in ab[:k] for l in c],reverse=True)
for i in res[:k]:
	print(i)
# Original solution
X, Y, Z, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

A = sorted(A)
B = sorted(B)
C = sorted(C)

maxn = A[0] * B[0] * C[0]

from heapq import *

h = []


heappush(h, (-A[-1] - B[-1] - C[-1], len(A) - 1, len(B) - 1, len(C) - 1))

used = {}

for i in range(min(K, X * Y * Z)):
    v, ix, iy, iz = heappop(h)
    print((-v))
    def push(x, y, z):
        if x >= 0 and y >= 0 and z >= 0 and (x, y, z) not in used:
            heappush(h, (-A[x] - B[y] - C[z], x, y, z))
            used[x, y, z] = 1
    push(ix - 1, iy, iz)
    push(ix, iy - 1, iz)
    push(ix, iy, iz - 1)



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


# Priority QueueとしてHeapを使う
# Pythonのheapqは小さい順に取り出すので、-1を掛けて負数としてpushしていく
#   (-Ai-Bj-Ck, i, j, k)
# 取り出したi, j, kについて、(i+1, j, k), (i, j+1, k), (i, j, k+1)に対応するタプルをpushする
# ただし、すでにpushした値は入れないようにする

import heapq

def make(i, j, k):
    return (-A[i]-B[j]-C[k], i, j, k)


used = set()
l = []

heapq.heappush(l, make(0, 0, 0))
used.add((0, 0, 0))

for cnt in range(K):
    V, i, j, k = heapq.heappop(l)
    
    if i < X - 1 and (i+1, j, k) not in used:
        heapq.heappush(l, make(i+1, j, k))
        used.add((i+1, j, k))
    
    if j < Y - 1 and (i, j+1, k) not in used:
        heapq.heappush(l, make(i, j+1, k))
        used.add((i, j+1, k))
    
    if k < Z - 1 and (i, j, k+1) not in used:
        heapq.heappush(l, make(i, j, k+1))
        used.add((i, j, k+1))
    
    print((-V))
# Original solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


X,Y,Z,K = MI()
A,B,C = LI(),LI(),LI()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

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

ANS.sort(reverse=True)
print(*ANS[:K],sep='\n')


# Optimized solution
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


X,Y,Z,K = MI()
A,B,C = LI(),LI(),LI()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

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

ANS.sort(reverse=True)
print(*ANS[: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()))


x = []
for a in A:
    for b in B:
        for c in C:
            x.append(a + b + c)
x.sort(reverse=True)

for i in range(K):
    print((x[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 range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse = True)

abc = []
for i in range(min(3000, len(ab))):
    for j in range(z):
        abc.append(ab[i] + c[j])
abc.sort(reverse = True)

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

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse = True)

abc = []
for i in range(min(k,len(ab))):
    for j in range(z):
        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()))
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 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)

for i in range(k):
    print((abc[i]))
# 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()]
d=[]
ans=[]
for i in a:
    for j in b:
        d.append(i+j)
for i in c:
    for j in d:
        ans.append(i+j)
ans.sort(reverse=True)
for i in range(k):
    print((ans[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)
if k>x: a=a[:k]
if k>y: b=b[:k]
if k>z: c=c[:k]
d=[]
ans=[]
for i in a:
    for j in b:
        d.append(i+j)
d.sort(reverse=True)
if len(d)>k: d=d[:k]
for i in c:
    for j in d:
        ans.append(i+j)
ans.sort(reverse=True)
for i in range(k):
    print((ans[i]))
# 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)
if k<x: a=a[:k]
if k<y: b=b[:k]
if k<z: c=c[:k]
d=[]
ans=[]
for i in a:
    for j in b:
        d.append(i+j)
d.sort(reverse=True)
if len(d)<k: d=d[:k]
for i in c:
    for j in d:
        ans.append(i+j)
ans.sort(reverse=True)
for i in range(k):
    print((ans[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)
if k<x: a=a[:k]
if k<y: b=b[:k]
if k<z: c=c[:k]
d=[]
ans=[]
for i in a:
    for j in b:
        d.append(i+j)
d.sort(reverse=True)
if k<len(d): d=d[:k]
for i in c:
    for j in d:
        ans.append(i+j)
ans.sort(reverse=True)
for i in range(k):
    print((ans[i]))
# Original solution
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')


if __name__ == '__main__':
    main()


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


if __name__ == '__main__':
    main()