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.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
sum_list = []
for a_i in range(x):
    for b_i in range(y):
        for c_i in range(z):
            if a_i*b_i*c_i > k:
                continue
            sum_list.append(a[a_i]+b[b_i]+c[c_i])
sum_list.sort(reverse=True)
for i in range(k):
    print((sum_list[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)
sum_list = []
for a_i in range(x):
    for b_i in range(y):
        if a_i*b_i > k:
            break
        for c_i in range(z):
            if a_i*b_i*c_i > k:
                break
            sum_list.append(a[a_i]+b[b_i]+c[c_i])
sum_list.sort(reverse=True)
for i in range(k):
    print((sum_list[i]))
# Original solution
import sys
input = sys.stdin.readline

X, Y, Z, K = map(int, 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()]

ablst = [m + n for n in b for m in a]

ablst.sort(reverse=True)

c.sort(reverse=True)

abclst = [m + n for n in c[:K] for m in ablst[:K]]

abclst.sort(reverse=True)

print(*abclst[:K], sep='\n')


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

X, Y, Z, K = map(int, 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()]

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

ablst = [m + n for n in b for m in a]

ablst.sort(reverse=True)

c.sort(reverse=True)

abclst = [m + n for n in c[:K] for m in ablst[:K]]

abclst.sort(reverse=True)

print(*abclst[: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()))

sum = []
for x in range(X):
    for y in range(Y):
        for z in range(Z):
            sum.append(A[x] + B[y] + C[z])

sum.sort(reverse=True)

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

A = A[:K+1]
B = B[:K+1]
C = C[:K+1]

E = []
for a in range(len(A)):
    for b in range(len(B)):
        E.append(A[a]+B[b])

E.sort(reverse=True)
E = E[:K+1]

ans = []
for c in range(len(C)):
    for e in range(len(E)):
        ans.append(C[c]+E[e])
        
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()))

E = []
for a in range(len(A)):
    for b in range(len(B)):
        E.append(A[a]+B[b])

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

ans = []
for c in range(len(C)):
    for e in range(len(E)):
        ans.append(C[c]+E[e])
        
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)

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

sum.sort(reverse=True)
for i in range(K):
    print((sum[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)
#print(AB)
AB = AB[:K]

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

for i in ABC:
    print(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 x in range(X):
    for y in range(Y):
        for z in range(Z):
            if (x+1)*(y+1)*(z+1) <= K:
                ABC.append(A[x]+B[y]+C[z])
            else:
                break

ABC.sort(reverse=True)
for i in range(K):
    print((ABC[i]))
# Original solution
x = 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()
a.reverse()

b.sort()
b.reverse()

c.sort()
c.reverse()

l = []

for i in range(x[0]):
    for j in range(x[1]):
        for k in range(x[2]):
            l.append(a[i]+b[j]+c[k])

l.sort()
l.reverse()

for i in range(x[3]):
    print((l[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()))

d = []
for xx in a:
    for yy in b:
        d.append(xx+yy)
d.sort()
d.reverse()


e = []
if len(d)>3000:
    for i in range(3000):
        for zz in c:
            e.append(d[i]+zz)
else:
    for xy in d:
        for zz in c:
            e.append(xy+zz)
e.sort()
e.reverse()

for i in range(k):
    print((e[i]))
# Original solution
from bisect import bisect_left

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

bc = [x + y for y in c for x in b]
bc.sort()
bcl = len(bc)

def bs_l(f, high, low=0):
    l, r = low-1, high+1
    while r - l > 1:
        x = (l + r) // 2
        if f(x): l = x
        else: r = x
    return l

def detect(s):
    cnt = 0
    for x in a:
        t = max(0, s-x)
        cnt += bcl - bisect_left(bc, t)
    return cnt >= k

res = bs_l(detect, 10**10+1)
ans = []
for x in a:
    t = max(0, res-x)
    for i in range(bcl-1, bisect_left(bc, t)-1, -1):
        ans.append(x + bc[i])

ans.sort(reverse=True)
print(*ans[: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)
bc = [x + y for y in c for x in b]
bc.sort(reverse=True)
ans = [x + y for y in a for x in bc[:k]]
ans.sort(reverse=True)
print(*ans[:k], sep="\n")
# Original solution
import math
import sys

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

x=sorted(list(map(int,input().split())),reverse=True)
y=sorted(list(map(int,input().split())),reverse=True)
z=sorted(list(map(int,input().split())),reverse=True)



"""
if X*Y*Z<=3000:
    ans=[]
    for i in range(X):
        for j in range(Y):
            for k in range(Z):  ans.append(x[i]+y[j]+z[k])
    ans.sort()
    for i in range(min(3000,X*Y*Z)):
        print(ans[i])
    sys.exit()
"""

yz=[]
for i in range(Y):
    yz=yz+[ y[i]+z[j] for j in range(Z)]

yz.sort(reverse=True)

if len(yz)>K:
    yz=yz[:K]


n=len(yz)
ans=[]

for i in range(X):
    tmp=[yz[j]+x[i] for j in range(len(yz))]
    ans =ans+tmp

ans.sort(reverse=True)


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


# Optimized solution
import math
import sys

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

x=sorted(list(map(int,input().split())),reverse=True)
y=sorted(list(map(int,input().split())),reverse=True)
z=sorted(list(map(int,input().split())),reverse=True)



"""
if X*Y*Z<=3000:
    ans=[]
    for i in range(X):
        for j in range(Y):
            for k in range(Z):  ans.append(x[i]+y[j]+z[k])
    ans.sort()
    for i in range(min(3000,X*Y*Z)):
        print(ans[i])
    sys.exit()
"""

ans=[]
for i in range(min(X,K)):
    tmp1=math.ceil(K/(i+1))
    for j in range(min(Y,tmp1)):
        tmp2=math.ceil(tmp1/(j+1))
        for k in range(min(Z,tmp2)):
            ans.append(x[i]+y[j]+z[k])

ans.sort(reverse=True)
for i in range(K):
    print((ans[i]))
# Original solution
input_out_data = input().split(" ")
cake_sum_point = []

for i in range(4):
    input_out_data[i] = int(input_out_data[i])


cake_A = input().split(" ")
cake_B = input().split(" ")
cake_C = input().split(" ")
for k in range(input_out_data[0]):
    cake_A[k] = int(cake_A[k])
cake_A.sort(reverse=True)
for k in range(input_out_data[1]):
    cake_B[k] = int(cake_B[k])
cake_B.sort(reverse=True)
for k in range(input_out_data[2]):
    cake_C[k] = int(cake_C[k])
cake_C.sort(reverse=True)

for i in range(input_out_data[0]):
    for k in range(input_out_data[1]):
        for j in range(input_out_data[2]):
            cake_sum_point.append(cake_A[i]+cake_B[k]+cake_C[j])
cake_sum_point.sort(reverse=True)
for i in range(input_out_data[3]):
    print((cake_sum_point[i]))

# Optimized solution
input_out_data = input().split(" ")
cake_sum_point = []

for i in range(4):
    input_out_data[i] = int(input_out_data[i])


cake_A = input().split(" ")
cake_B = input().split(" ")
cake_C = input().split(" ")
for k in range(input_out_data[0]):
    cake_A[k] = int(cake_A[k])
cake_A.sort(reverse=True)
for k in range(input_out_data[1]):
    cake_B[k] = int(cake_B[k])
cake_B.sort(reverse=True)
for k in range(input_out_data[2]):
    cake_C[k] = int(cake_C[k])
cake_C.sort(reverse=True)

for i in range(input_out_data[0]):
    for k in range(input_out_data[1]):
        for j in range(input_out_data[2]):
            if (i+1)*(k+1)*(j+1)<=input_out_data[3]:
                cake_sum_point.append(cake_A[i]+cake_B[k]+cake_C[j])
cake_sum_point.sort(reverse=True)
for i in range(input_out_data[3]):
    print((cake_sum_point[i]))
# Original solution
x,y,z,q=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)
 
def bisect(l,r):
  cnt=(l+r)//2
  if cnt==l:
    return l-1+judge(l)
  if judge(cnt):
    return bisect(cnt+1,r)
  else:
    return bisect(l,cnt)
def judge(thr):
  m=0
  for i in range(x):
    for j in range(y):
      for k in range(z):
        if i*j*k>q or a[i]+b[j]+c[k]<thr:
          break
        m+=1
        if m>=q:
          return True
  return False
def make(thr):
  m=0
  l=[]
  for i in a:
    for j in b:
      for k in c:
        n=i+j+k
        if n<thr+1:
          break
        m+=1
        l+=[n]
  l.sort(reverse=True)
  return l+[thr]*(q-len(l))
thr=bisect(0,a[0]+b[0]+c[0]+1)
ans=make(thr)
for w in ans:
  print(w)

# Optimized solution
x,y,z,q=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)
l=[]
for i in range(x):
  for j in range(y):
    if i*j>q:
      break
    for k in range(z):
      if i*j*k>q:
        break
      l+=[a[i]+b[j]+c[k]]
l.sort(reverse=True)
for w in l[:q]:
  print(w)
# 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()))
if X<Y and X<Z:
  X,Z=Z,X
  A,C=C,A
elif Y<X and Y<Z:
  Y,Z=Z,Y
  B,C=C,Y
C=sorted(C,reverse=True)
k=min(K,X*Y)
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[:K]],reverse=True)[:K]
for x in ABC:
  print(x)


# 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)
ans=[]
for i in range(X):
  if i+1>K:
    break
  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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  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()))
sum = 0
ans = []
ans2 = []

for i in range(X):
    for j in range(Y):
        sum = A[i] + B[j]
        ans.append(sum)
ans.sort(reverse=True)

for i in range(min(K,len(ans))):
    for j in range(Z):
        sum = ans[i] + C[j]
        ans2.append(sum)
ans2.sort(reverse=True)

for l in range(K):
    print((ans2[l]))

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

ans = []

for i in range(X):
    for j in range(Y):
        if (i+1)*(j+1) > K:
            break
        for t in range(Z):
            if (i+1)*(j+1)*(t+1) > K:
                break
            ans.append(A[i]+B[j]+C[t])
ans.sort(reverse=True)

for l in range(K):
    print((ans[l]))
# 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)
done = [[[True for _ in range(Z+1)] for _ in range(Y+1)] for _ in range(Z+1)]

h = []
heapq.heappush(h, (-(A[0]+B[0]+C[0]), 0, 0, 0))  # リストaのheap化
done[0][0][0] = False

for _ in range(K):
    p, i, j, k = heapq.heappop(h)
    # print(h)
    print((-p))

    if done[i+1][j][k] and i+1 < X:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i+1]+B[j]+C[k]), i+1, j, k))
        # print(h)
        done[i+1][j][k] = False

    if done[i][j+1][k] and j+1 < Y:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i]+B[j+1]+C[k]), i, j+1, k))
        # print(h)
        done[i][j+1][k] = False

    if done[i][j][k+1] and k+1 < Z:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i]+B[j]+C[k+1]), i, j, k+1))
        # print(h)
        done[i][j][k+1] = False


# 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)
# done = [[[True for _ in range(Z+1)] for _ in range(Y+1)] for _ in range(Z+1)]
done = []

h = []
heapq.heappush(h, (-(A[0]+B[0]+C[0]), 0, 0, 0))  # リストaのheap化
done.append((0, 0, 0))

for _ in range(K):
    p, i, j, k = heapq.heappop(h)
    # print(h)
    print((-p))

    if (i+1, j, k) not in done and i+1 < X:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i+1]+B[j]+C[k]), i+1, j, k))
        # print(h)
        done.append((i+1, j, k))

    if (i, j+1, k) not in done and j+1 < Y:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i]+B[j+1]+C[k]), i, j+1, k))
        # print(h)
        done.append((i, j+1, k))

    if (i, j, k+1) not in done and k+1 < Z:
        # heap化されたリストaに要素xを追加
        heapq.heappush(h, (-(A[i]+B[j]+C[k+1]), i, j, k+1))
        # print(h)
        done.append((i, j, k+1))
# 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)

done = [[[False for k in range(Z)] for j in range(Y)] for i in range(X)]
done[0][0][0] = True

hq = [(-(A[0]+B[0]+C[0]), 0, 0, 0)]
heapq.heapify(hq)  # リストhqのheap化

ans = 0
D = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]

for _ in range(K):
    s, i, j, k = heapq.heappop(hq)  # heap化されたリストhqから最小値を削除＆その最小値を出力
    print((-s))
    for d in D:
        ni, nj, nk = i+d[0], j+d[1], k+d[2]
        if ni < X and nj < Y and nk < Z and done[ni][nj][nk] is False:
            # heap化されたリストhqに要素xを追加
            heapq.heappush(hq, (-(A[ni]+B[nj]+C[nk]), ni, nj, nk))
            done[ni][nj][nk] = True


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

done = {(0, 0, 0)}

hq = [(-(A[0]+B[0]+C[0]), 0, 0, 0)]
heapq.heapify(hq)  # リストhqのheap化

ans = 0
D = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]

for _ in range(K):
    s, i, j, k = heapq.heappop(hq)  # heap化されたリストhqから最小値を削除＆その最小値を出力
    print((-s))
    for d in D:
        ni, nj, nk = i+d[0], j+d[1], k+d[2]
        if ni < X and nj < Y and nk < Z and (ni, nj, nk) not in done:
            # heap化されたリストhqに要素xを追加
            heapq.heappush(hq, (-(A[ni]+B[nj]+C[nk]), ni, nj, nk))
            done.add((ni, nj, nk))
# Original solution
import sys
from heapq import heappush,heapify,heappop
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()))
d = [i + j for i in a for j in b]
d.sort(reverse=1)
c.sort(reverse=1)
q = [(-d[0] - c[0], 0, 0)]
for _ in range(k):
    v, s, t = heappop(q)
    print((-v))
    if t + 1 < z:
        heappush(q, (-d[s] - c[t + 1], s, t + 1))
    if t == 0 and s + 1 < x * y:
        heappush(q, (-d[s + 1] - c[0], s + 1, 0))

# Optimized solution
# O(klog(k))解法 多分...
import sys
from heapq import heappush,heapify,heappop
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()))

def make_kth(A, B):
    n, m = len(A), len(B)
    A.sort(reverse=1)
    B.sort(reverse=1)
    q = [(-A[0] - B[0], 0, 0)]
    r=[]
    for _ in range(min(k, n * m)):
        v, s, t = heappop(q)
        r.append(-v)
        if t + 1 < m:
            heappush(q, (-A[s] - B[t + 1], s, t + 1))
        if t == 0 and s + 1 < n:
            heappush(q, (-A[s + 1] - B[0], s + 1, 0))
    return r

r = make_kth(a, b)
r = make_kth(c, r)
print(*r,sep="\n")
# Original solution
# -*- coding: utf-8 -*-


def main():
    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)
    count = min(x * z, k)
    ac = list()
    ans = list()

    for ai in a:
        for ci in c:
            ac.append(ai + ci)

    for bi in b:
        for ac_i in sorted(ac, reverse=True)[:count]:
            ans.append(bi + ac_i)

    for j in sorted(ans, reverse=True)[:k]:
        print(j)


if __name__ == '__main__':
    main()


# Optimized solution
# -*- coding: utf-8 -*-


def main():
    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)
    ac = list()

    for ai in a:
        for ci in c:
            ac.append(ai + ci)

    count = min(x * z, k)
    acs = sorted(ac, reverse=True)[:count]
    ans = list()

    for bi in b:
        for ac_i in acs:
            ans.append(bi + ac_i)

    for j in sorted(ans, reverse=True)[:k]:
        print(j)


if __name__ == '__main__':
    main()
# Original solution
from heapq import heappop,heappush;import sys;input=sys.stdin.readline
x,y,z,k=list(map(int,input().split()));a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))
q,h,l=[],[],0
for i in a:
  for j in b:heappush(q,-(i+j));l+=1
for _ in range(min(l,k)):
  t=heappop(q)
  for i in c:heappush(h,t-i)
for i in range(k):print((-heappop(h)))

# Optimized solution
x,y,z,k=list(map(int,input().split()));a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))
aa=[]
for i in a:
  for j in b:aa.append(i+j)
aa.sort(reverse=1)
aa=aa[:k+1]
s=[]
for i in aa:
  for j in c:s.append(i+j)
s.sort(reverse=1)
for i in range(k):print((s[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()] 

ans = []
for x in range(X):
    for y in range(Y):
        for z in range(Z):
            ans.append(A[x]+B[y]+C[z])
ans.sort(reverse=True)
for k in range(K):
    print((ans[k]))

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

ans = []
for x in range(X):
    for y in range(Y):
        ans.append(A[x]+B[y])

ans.sort(reverse=True)
C.sort(reverse=True)
ans2 = []
for k in range(min(K,X*Y)):
    for z in range(min(Z,K)):
        ans2.append(ans[k]+C[z])
ans2.sort(reverse=True)

for k in range(K):
    print((ans2[k]))
# 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_pls_y = []

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

xy_pls_z = []

for i in range(min(3000,x*y)):
    for j in range(z):
        xy_pls_z.append(x_pls_y[i]+c[j])
        
xy_pls_z.sort(reverse=True)

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

kouho = []

for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            kouho.append(a[i]+b[j]+c[k])


kouho.sort(reverse=True)

for i in range(K):
    print((kouho[i]))
# 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()))
ab = list()
for a in A:
    for b in B:
        ab.append(a+b)
ab.sort(reverse=True)
C.sort(reverse=True)
abc = []
for a in ab[:k]:
    for b in C:
        abc.append(a+b)
abc.sort(reverse=True)
print(*abc[:k], sep="\n")


# Optimized solution
import heapq as hq
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:
        hq.heappush(ab, -a-b)
abc = []
cnt = 0
while cnt < k and ab:
    cnt += 1
    a = hq.heappop(ab)
    for b in C:
        hq.heappush(abc, a-b)
cnt = 0
while cnt < k:
    print((-hq.heappop(abc)))
    cnt += 1