CodeEff/ECCO huggingface dataset:
# Original solution
import heapq

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)

anslist = []
flag = [[[False for _ in range(K)] for _ in range(K)] for _ in range(K)]

heapq.heappush(anslist, (-(A[0]+B[0]+C[0]), "000"))
count = 0

while count < K:
    p = heapq.heappop(anslist)
    print((p[0]*(-1)))
    count += 1
    # push
    a, b, c = list(map(int, p[1]))
    for i, j, k in [[1, 0, 0], [0, 1, 0], [0, 0, 1]]:
        if a+i >= X or b+j >= Y or c+k >= Z:
            continue
        if not flag[a+i][b+j][c+k]:
            flag[a+i][b+j][c+k] = True
            tmp = str(a+i)+str(b+j)+str(c+k)
            heapq.heappush(anslist, (-(A[a+i]+B[b+j]+C[c+k]), tmp))


# Optimized solution
import heapq


class Delicious (object):
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

    def total(self):
        return(A[self.x] + B[self.y] + C[self.z])

    def __lt__(self, other):
        return self.total() > other.total()


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)

ds = []
heapq.heappush(ds, Delicious(0, 0, 0))

check = {}

for _ in range(K):
    d = heapq.heappop(ds)
    while (d.x, d.y, d.z) in check:
        d = heapq.heappop(ds)
    print((d.total()))
    check[d.x, d.y, d.z] = True

    if d.x < X-1:
        heapq.heappush(ds, Delicious(d.x+1, d.y, d.z))
    if d.y < Y-1:
        heapq.heappush(ds, Delicious(d.x, d.y+1, d.z))
    if d.z < Z-1:
        heapq.heappush(ds, Delicious(d.x, d.y, d.z+1))
# 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)
useA = [a.pop(0)]
useB = [b.pop(0)]
useC = [c.pop(0)]
if len(a) == 0:
  a.append(0)
if len(b) == 0:
  b.append(0)
if len(c) == 0:
  c.append(0)
while True:
  if a[0] == b[0] == c[0] == 0:
    break
  if a[0] >= b[0] and a[0] >= c[0]:
    useA.append(a.pop(0))
    if len(a) == 0:
      a.append(0)
  elif b[0] >= a[0] and b[0] >= c[0]:
    useB.append(b.pop(0))
    if len(b) == 0:
      b.append(0)
  elif c[0] >= b[0] and c[0] >= a[0]:
    useC.append(c.pop(0))
    if len(c) == 0:
      c.append(0)
#  print( len(useA) * len(useB) * len(useC))
  if 1000*k**2 <= len(useA) * len(useB) * len(useC):
    break
ans = []
#print(useA, useB, useC)
for i in range(len(useA)):
  for j in range(len(useB)):
    for m in range(len(useC)):
      ans.append(useA[i] + useB[j] + useC[m])
ans.sort(reverse = True)
for i in range(k):
  print((ans[i]))

# Optimized 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)
def search(a, b):
  ret = []
  al = len(a)
  bl = len(b)
  for i in range(min(al, k)):
    for j in range(min(bl, k-i)):
      ret.append(a[i] + b[j])
  ret.sort(reverse = True)
  return ret
d = search(a, b)      
e = search(c, d)    

for i in range(k):
  print((e[i]))
# 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=a[:k]
b=b[:k]

sum_ab=[]

for i in a:
    for j in b:
      sum_ab.append(i+j)

sorted(sum_ab,reverse=True)

sum_abc=[]
for i in sum_ab:
    for j in c:
      sum_abc.append(i+j)

sum_abc.sort(reverse=True)
for v in sum_abc[:k]:
    print(v)

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

sum_ab=[]

for i in a:
    for j in b:
      sum_ab.append(i+j)

sum_ab.sort(reverse=True)
sum_ab= sum_ab[:k]

sum_abc=[]
for i in sum_ab:
    for j in c:
      sum_abc.append(i+j)

sum_abc.sort(reverse=True)
for v in sum_abc[:k]:
    print(v)
# Original solution
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r


x, y, z, k = map(int, sys.stdin.readline().split())
a, b, c = (sorted(map(int, sys.stdin.readline().split())) for _ in range(3))

def count_atleast_k(border):
    combs = 0
    for i in range(x):
        for j in range(y):
            combs += z - bi_r(c, border - a[i] - b[j])
    return combs >= k

def main():
    hi = 3 * 10 ** 10 + 1
    lo = 2
    while lo + 1 < hi:
        border = (lo + hi) // 2
        if count_atleast_k(border):
            lo = border
        else:
            hi = border

    res = []
    for i in range(x-1, -1, -1):
        if hi - a[i] > b[-1] + c[-1]:
            break
        for j in range(y-1, -1, -1):
            if hi - a[i] - b[j] > c[-1]:
                break
            for k in range(z-1, -1, -1):
                if hi - a[i] - b[j] - c[k] > 0:
                    break
                res.append(a[i] + b[j] + c[k])
    
    return sorted(res, reverse=True)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')


# Optimized solution
import sys
from heapq import heappush, heappop

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

def main():
    cand = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
    added = set([(0, 0, 0)])
    for _ in range(K):
        s, i, j, k = heappop(cand)
        yield -s
        if i + 1 < x and not (i+1, j, k) in added:
            heappush(cand, (s + a[i] - a[i+1], i+1, j, k))
            added.add((i+1, j, k))
        if j + 1 < y and not (i, j+1, k) in added:
            heappush(cand, (s + b[j] - b[j+1], i, j+1, k))
            added.add((i, j+1, k))
        if k + 1 < z and not (i, j, k+1) in added:
            heappush(cand, (s + c[k] - c[k+1], i, j, k+1))
            added.add((i, j, k+1))

if __name__ == '__main__':
    ans = main()
    print(*ans, 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()))

# まずA, Bで総当たり、上位K個をスタック
tmp = [a+b for a in A for b in B]
tmp.sort(reverse=True)
tmp = tmp[:K]

# 残りのc個に対しても総当たり
ans = [t+c for t in tmp for c in C]
ans.sort(reverse=True)
ans = ans[:K]

for s in ans:
    print(s)

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

# まずA, Bで総当たり、上位K個をスタック
tmp = [a+b for a in A for b in B]
tmp.sort(reverse=True)
tmp = tmp[:K]

# 残りのc個に対しても総当たり
ans = [t+c for t in tmp for c in C]
ans.sort(reverse=True)
ans = ans[:K]
for s in ans:
    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()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
li = []
for i in a:
    for j in b:
        li.append(i + j) 
li.sort(reverse = True)
li = li[:min(k,x*y)]
box = []
for i in li:
    for j in c:
        box.append(i + j)
box.sort(reverse = True)
for i in range(k):
    print((box[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)
li = []
box = []
for i in a:
    for j in b:
        li.append(i + j) 
li.sort(reverse = True)
li = li[:min(k,x*y)]
for i in c:
    for j in li:
        box.append(i + j)
box.sort(reverse = True)
for i in range(k):
    print((box[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)
tot = []
for i in range(X):
   for j in range(Y):
      for k in range(Z):
         if(i*j*k > K): break
         else: tot.append(a[i] + b[j] + c[k])
tot.sort()
for i in range(K):
   print((tot[-(i+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)
tot = []
for i in range(X):
   for j in range(Y):
      for k in range(Z):
         if((i+1)*(j+1)*(k+1) <= K): tot.append(a[i] + b[j] + c[k])
         else: break
tot.sort(reverse = True)
for i in range(K):print((tot[i]))
# Original solution
import heapq
#Aの中でa番目、Bの中でb番目、Cの中でc番目のものがabc > Kの時、大きい順のK番目以内にabcの組が入ることはない
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)

h = []
check = [[[0] * Z for _ in range(Y)] for _ in range(X)]
heapq.heappush(h, [-(A[0]+B[0]+C[0]), 0, 0, 0])
check[0][0][0] = 1
for count in range(K):
    ans = heapq.heappop(h)
    i, j , k = ans[1], ans[2], ans[3]
    print((-ans[0]))
    if i + 1 < X:
        if check[i+1][j][k] == 0:
            heapq.heappush(h, [-(A[i+1]+B[j]+C[k]), i+1, j, k])
            check[i+1][j][k] = 1
    if j + 1 < Y:
        if check[i][j+1][k] == 0:
            heapq.heappush(h, [-(A[i]+B[j+1]+C[k]), i, j+1, k])
            check[i][j+1][k] = 1
    if k + 1 < Z:
        if check[i][j][k+1] == 0:
            heapq.heappush(h, [-(A[i]+B[j]+C[k+1]), i, j, k+1])
            check[i][j][k+1] = 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()))

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

bi_comb = []
for i in range(min(X, K)):
    for j in range(min(Y, K)):
        if (i+1)*(j+1) <= K:
            bi_comb += [A[i]+B[j]]
bi_comb.sort(reverse = True)

tri_comb = []
for k in range(min(len(bi_comb), K)):
    for l in range(min(Z, K)):
        if (k+1)*(l+1) <= K:
            tri_comb += [bi_comb[k]+C[l]]
tri_comb.sort(reverse = True)

print (*tri_comb[: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()))
D=[]
for i in range(X):
    for j in range(Y):
        D.append(A[X-1-i]+B[Y-1-j])
D.sort()
ans=[]
for i in range(min(K,len(D))):
    for j in range(min(K,Z)):
        ans.append(D[len(D)-1-i]+C[Z-1-j])
ans.sort()
for i in range(K):
    print((ans[len(ans)-1-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)
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]))
# 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=[a+b for a in A for b in B]
AB.sort(reverse=True)

ABC=[ab+c for ab in AB[:min(k,x*y)] for c in 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=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)


AB=[a+b for a in A for b in B]
AB.sort(reverse=True)

ABC=[ab+c for ab in AB[:min(k,x*y)] for c in C]
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()))
ans=[]
for i in range(x):
    for j in range(y):
        for n in range(z):
            ans.append(a[i]+b[j]+c[n])
ans.sort()
ans=ans[::-1]
cnt=0
while cnt!=k:
    print((ans[cnt]))
    cnt+=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()))
ab=[s+t for s in a for t in b]
ab.sort()
ab=ab[-1:-k-1:-1]
abc=[s+t for s in ab for t in c]
abc.sort()
abc=abc[-1:-k-1:-1]
for i in range(len(abc)):
    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=[s+t for s in a for t in b]
ab.sort()
ab=ab[-1:-k-1:-1]
abc=[s+t for s in ab for t in c]
abc.sort()
abc=abc[-1:-k-1:-1]
for i in range(len(abc)):
    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=sorted([s+t for s in a for t in b])[-1:-k-1:-1]
abc=sorted([s+t for s in ab for t in c])[-1:-k-1:-1]
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()))
temp_sum = []
for i in range(X):
	for j in range(Y):
		for k in range(Z):
			temp_sum.append(A[i] + B[j] + C[k])

def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

ans = merge_sort(temp_sum)

for i in range(K):
	print((ans[len(ans) - 1 - 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()))
ans = []
A.sort()
A.reverse()
B.sort()
B.reverse()
C.sort()
C.reverse()
for i in range(min(K,len(A))):
	if K // (i+1) > 0:
		for j in range(min(K // (i+1),len(B))):
			if K // ((i+1) * (j+1)) > 0:
				for l in range(min(K // ((i+1) * (j+1)),len(C))):
					ans.append(A[i] + B[j] + C[l])

ans.sort()
ans.reverse()
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)            

ab=[]

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

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

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

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
abc = sorted(x+y for x in ab[:k] for y in c)[:-k-1:-1]
print(*abc, sep='\n')
# 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()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
c = c[:k]
abc = []
for i in ab:
    for j in c:
        abc.append(i+j)
abc.sort(reverse=True)

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


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

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
c = c[:k]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]

print(*abc[:k], sep="\n")
# Original solution
import sys
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()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
c = c[:k]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]

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


# Optimized solution
import sys
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=sorted(int(i) for i in input().split())

a.sort(reverse=True)
b.sort(reverse=True)
#c.sort(reverse=True)

ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
c = c[:k]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]

print(*abc[:k], sep="\n")
# Original solution
import sys
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=sorted(int(i) for i in input().split())[:-k-1:-1]

a.sort(reverse=True)
b.sort(reverse=True)
#c.sort(reverse=True)

ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]

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


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

x, y, z, k = map(int, input().split())
a = sorted(int(i) for i in input().split())
b = sorted(int(i) for i in input().split())
c = sorted(int(i) for i in input().split())

#a.sort(reverse=True)
#b.sort(reverse=True)
#c.sort(reverse=True)

ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]

print(*abc[:k], sep="\n")
# Original solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

A=sorted(A)[::-1]
B=sorted(B)[::-1]
C=sorted(C)[::-1]
ans = []
for i in range(len(A)):
	if i > K:
		continue
	for j in range(len(B)):
		if i * j > K:
			continue
		for k in range(len(C)):
			if i * j * k > K:
				continue
			else:
				ans.append(A[i]+B[j]+C[k])
for i in sorted(ans)[::-1][0:K]:
	print(i)

# Optimized solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

A=sorted(A)[::-1]
B=sorted(B)[::-1]
C=sorted(C)[::-1]
ans = []
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:
				ans.append(A[i]+B[j]+C[k])
			else:
				break
for i in sorted(ans)[::-1][0:K]:
	print(i)
# Original solution
#!/usr/bin/python
import sys
import heapq
R=lambda:list(map(int,sys.stdin.readline().split()))
xa,xb,xc,k=R()
a=sorted(R())
b=sorted(R())
c=sorted(R())
h=set()
q=[[-(a[-1]+b[-1]+c[-1]),xa-1,xb-1,xc-1]]
for _ in range(k):
	x,ya,yb,yc=heapq.heappop(q)
	print((-x))
	if ya>0 and (ya-1,yb,yc) not in h:
		h.add((ya-1,yb,yc))
		heapq.heappush(q,[x+a[ya]-a[ya-1],ya-1,yb,yc])
	if yb>0 and (ya,yb-1,yc) not in h:
		h.add((ya,yb-1,yc))
		heapq.heappush(q,[x+b[yb]-b[yb-1],ya,yb-1,yc])
	if yc>0 and (ya,yb,yc-1) not in h:
		h.add((ya,yb,yc-1))
		heapq.heappush(q,[x+c[yc]-c[yc-1],ya,yb,yc-1])

# Optimized solution
import sys,heapq
R=lambda:list(map(int,sys.stdin.readline().split()))
x=list(R())
k=x.pop()
a=[sorted(R())for _ in range(3)]
h=set()
q=[[-sum(e[-1] for e in a)]+[e-1 for e in x]]
for _ in range(k):
	y=heapq.heappop(q)
	x=y.pop(0)
	print((-x))
	for i in range(3):
		ny=list(y)
		ny[i]-=1
		if y[i] and tuple(ny) not in h:
			h.add(tuple(ny))
			heapq.heappush(q,[x+a[i][y[i]]-a[i][y[i]-1]]+ny)
# 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)
AB = []
for a in A:
    for b in B:
        AB.append(a+b)
AB.sort(reverse=True)
AB = AB[0:min(3001,X*Y*Z+1)]

ABC = []
for ab in AB:
    for c in C:
        ABC.append(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()))
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]))
# Original solution
import sys,bisect
input = sys.stdin.readline
 
x,y,z,k = list(map(int,input().split()))
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
c = tuple(map(int,input().split()))
 
ab = []
for e in a:
    for w in b:
        ab.append(e+w)
ab.sort()
 
ok = -1
ng = 10**11
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    cnt = 0
    for e in c:
        cnt += len(ab)-bisect.bisect_left(ab,mid-e)
    if cnt >= k:
        ok = mid
    else:
        ng = mid
 
res = []
for e in c:
    ind = bisect.bisect_left(ab,ok-e)
    for i in range(ind,len(ab)):
        res.append(e+ab[i])
res.sort()
for i in range(1,k+1):
    print((res[-i]))

# Optimized solution
import sys,bisect
input = sys.stdin.readline
def main():
    x,y,z,k = list(map(int,input().split()))
    a = tuple(map(int,input().split()))
    b = tuple(map(int,input().split()))
    c = tuple(map(int,input().split()))
    
    ab = []
    for e in a:
        for w in b:
            ab.append(e+w)
    ab.sort()
    
    ok = -1
    ng = 10**11
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        cnt = 0
        for e in c:
            cnt += len(ab)-bisect.bisect_left(ab,mid-e)
        if cnt >= k:
            ok = mid
        else:
            ng = mid
    
    res = []
    for e in c:
        ind = bisect.bisect_left(ab,ok-e)
        for i in range(ind,len(ab)):
            res.append(e+ab[i])
    res.sort()
    for i in range(1,k+1):
        print((res[-i]))
if __name__ == '__main__':
    main()