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)
h = []
for i in range(x):
    for j in range(y):
        for l in range(z):
            if(i*j*l>k): break
            h.append(a[i] + b[j] +c[l])
h.sort(reverse = True)
for i in range(k):
    print((h[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)
h = []
for i in range(x):
    for j in range(y):
        if(i*j>k): break
        for l in range(z):
            if(i*j*l>k): break
            h.append(a[i] + b[j] +c[l])
h.sort(reverse = True)
for i in range(k):
    print((h[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()))

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

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

L2=[]
for ab in L:
	for c in C:
		L2.append(ab+c)

L2.sort(reverse=True)

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

L=[]
for ia, a in enumerate(A):
	for ib, b in enumerate(B):
		for ic, c in enumerate(C):
			if (ia+1)*(ib+1)*(ic+1)<=K:
				L.append(a+b+c)
			else:
				break

L.sort(reverse=True)

for i in range(K):
	print(L[i])
# Original solution
def main():
    x,y,z,k = list(map(int,input().split()))
    lia = sorted(list(map(int,input().split())))
    lib = sorted(list(map(int,input().split())))
    lic = sorted(list(map(int,input().split())))

    li2 = sorted(list(a+b for a in lia for b in lib),reverse = True)[:k]
    li3 = sorted(list(ab + c for ab in li2 for c in lic),reverse = True)

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

main()


# Optimized solution
def main():
    x,y,z,k = list(map(int,input().split()))
    lia = sorted(list(map(int,input().split())))
    lib = sorted(list(map(int,input().split())))
    lic = sorted(list(map(int,input().split())))

    li2 = sorted(list(a+b for a in lia for b in lib),reverse = True)[:k]
    li3 = sorted(list(ab + c for ab in li2 for c in lic),reverse = True)[:k]

    print(('\n'.join(map(str,li3))))

main()
# Original solution
x,y,z,k = list(map(int,input().split()))
lia = sorted(list(map(int,input().split())),reverse = True)
lib = sorted(list(map(int,input().split())),reverse = True)
lic = sorted(list(map(int,input().split())),reverse = True)
li = []

for s in range(x):
    for t in range(y):
        for u in range(z):
            if s*t*u <= k:
                li.append(lia[s]+lib[t]+lic[u])
ans = sorted(li,reverse = True)[:k]

print(('\n'.join(map(str,ans))))


# Optimized solution
x,y,z,k = list(map(int,input().split()))
lia = sorted(list(map(int,input().split())),reverse = True)
lib = sorted(list(map(int,input().split())),reverse = True)
lic = sorted(list(map(int,input().split())),reverse = True)
li = []

for s in range(x):
    for t in range(y):
        if s*t > k: break
        for u in range(z):
            if s*t*u <= k:
                li.append(lia[s]+lib[t]+lic[u])
            else: break
ans = sorted(li,reverse = True)[:k]

print(('\n'.join(map(str,ans))))
# Original solution
def cake(s1,s2,s3):
    ans1 = sorted(i+j for i in s1 for j in s2)
    ans2 = sorted(i+j for i in ans1 for j in s3)
    return ans2    
    
a,b,c,d = list(map(int, input().split()))

s1=list(map(int, input().split()))
s2=list(map(int, input().split()))
s3=list(map(int, input().split()))

z = sorted(cake(s1,s2,s3),reverse=True)
for i in range(0,d):
    print((z[i]))

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


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

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 = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab = sorted(ab)[::-1][:k]
abc = []
for i in range(min(k, x*y)):
    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 = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in 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, x*y)):
    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 = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in 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, x*y)):
    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, o = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])[::-1]
b = sorted([int(_) for _ in input().split()])[::-1]
c = sorted([int(_) for _ in input().split()])[::-1]
s = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i+1)*(j+1)*(k+1) <= o:
                s.append(a[i]+b[j]+c[k])
            else:
                break
for ans in sorted(s)[::-1][:o]:
    print(ans)
# Original solution
x, y, z, o = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])[::-1]
b = sorted([int(_) for _ in input().split()])[::-1]
c = sorted([int(_) for _ in input().split()])[::-1]

def isBorder(p):
    l = []
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if a[i]+b[j]+c[k] < p : break
                l.append(a[i]+b[j]+c[k])
    return l if len(l) >= o else []

l, r = 0, a[0]+b[0]+c[0]
while True:
    if r==l : break
    p = (l+r)//2
    q = isBorder(p)
    if q == []:
        r = p-1
    else:
        l = p+1
q.sort(reverse=True)
for i in range(o):
    print((q[i]))


# Optimized solution
x, y, z, o = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])[::-1]
b = sorted([int(_) for _ in input().split()])[::-1]
c = sorted([int(_) for _ in input().split()])[::-1]

def isEnough(p):
    cnt = 0
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if a[i]+b[j]+c[k] < p : break
                cnt += 1
                if cnt >= o: return True
    return False

ok, ng = 0, a[0]+b[0]+c[0]
while abs(ok-ng)>1:
    m = (ok+ng)//2
    if isEnough(m):
        ok = m
    else:
        ng = m

l = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if a[i]+b[j]+c[k] <= ok : break
            l.append(a[i]+b[j]+c[k])
l.sort(reverse=True)
for i in range(o):
    if len(l) > i:
        print((l[i]))
    else:
        print(ok)
# 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)
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])

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)
ans = []
for i in range(X):
	for j in range(min(Y,K//(i+1)+1)):
		for k in range(min(Z,K//((i+1)*(j+1))+1)):
			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 = 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)

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

list1 = []
for i in range(len(list)):
    for j in range(z):
        list1.append(list[i]+c[j])
list1.sort(reverse = True)
list1 = list1[:k]

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

list = []
for aa in a:
    for bb in b:
        list.append(aa+bb)
list.sort(reverse = True)
list = list[:k]

list1 = []
for ab in list:
    for cc in c:
        list1.append(ab+cc)
list1.sort(reverse = True)
list1 = list1[:k]

for i in range(k):
    print((list1[i]))
# Original solution
X, Y, Z, K = [int(_) for _ in input().split()]
As = [int(_) for _ in input().split()]
Bs = [int(_) for _ in input().split()]
Cs = [int(_) for _ in input().split()]

As.sort()
Bs.sort()
Cs.sort()

choice_stack = [(len(As) - 1, len(Bs) - 1, len(Cs) - 1)]
choice_stack_next = []
choice_log = set()
sums = []

j = 0
while True:
    for Ai, Bi, Ci in choice_stack:
        sums.append(As[Ai] + Bs[Bi] + Cs[Ci])
        cA = (max(0, Ai - 1), Bi, Ci)
        cB = (Ai, max(0, Bi - 1), Ci)
        cC = (Ai, Bi, max(0, Ci - 1))
        if not (cA in choice_log):
            choice_stack_next.append(cA)
            choice_log.add(cA)
        if not (cB in choice_log):
            choice_stack_next.append(cB)
            choice_log.add(cB)
        if not (cC in choice_log):
            choice_stack_next.append(cC)
            choice_log.add(cC)

    sums.sort()
    print((sums.pop()))
    choice_stack = [_ for _ in choice_stack_next]
    choice_stack_next.clear()
    j += 1
    if j >= K:
        break


# Optimized solution
X, Y, Z, K = [int(_) for _ in input().split()]
As = [int(_) for _ in input().split()]
Bs = [int(_) for _ in input().split()]
Cs = [int(_) for _ in input().split()]

As.sort()
Bs.sort()
Cs.sort()

choice_stack = [(As[-1] + Bs[-1] + Cs[-1], len(As) - 1, len(Bs) - 1, len(Cs) - 1)]
choice_log = set()

j = 0
while True:
    choice_stack.sort()
    chosen_sum, Ai, Bi, Ci = choice_stack.pop()

    print(chosen_sum)

    step_A = (As[max(0, Ai - 1)] + Bs[Bi] + Cs[Ci], max(0, Ai - 1), Bi, Ci)
    step_B = (As[Ai] + Bs[max(0, Bi - 1)] + Cs[Ci], Ai, max(0, Bi - 1), Ci)
    step_C = (As[Ai] + Bs[Bi] + Cs[max(0, Ci - 1)], Ai, Bi, max(0, Ci - 1))

    if not (step_A in choice_log):
        choice_stack.append(step_A)
        choice_log.add(step_A)
    if not (step_B in choice_log):
        choice_stack.append(step_B)
        choice_log.add(step_B)
    if not (step_C in choice_log):
        choice_stack.append(step_C)
        choice_log.add(step_C)

    j += 1
    if j >= K:
        break
# Original solution
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)
c = c[:k]

e = []

cnt = 0
for va in a:
    for vb in b:
        heapq.heappush(e, -(va+vb))

d = []
while len(e):
    ve = -heapq.heappop(e)
    for vc in c:
        heapq.heappush(d, -(ve+vc))

for i in range(k):
    print((-heapq.heappop(d)))

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

e = []

for va in a:
    for vb in b:
        e.append(va+vb)

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

d = []
for ve in e:
    for vc in c:
        heapq.heappush(d, -(ve+vc))

for i in range(k):
    print((-heapq.heappop(d)))
# Original solution
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()))

e = []

for va in a:
    for vb in b:
        e.append(va+vb)

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

d = []
for ve in e:
    for vc in c:
        heapq.heappush(d, -(ve+vc))

for i in range(k):
    print((-heapq.heappop(d)))


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

e = []

# AxB を取得
for va in a:
    for vb in b:
        heapq.heappush(e, -(va+vb))

# AxB は 大きい方から最大k個のみ使う
d = []
ite = min(k, len(e))

# AxB[k個] x C を取得
for i in range(ite):
    ve = -heapq.heappop(e)
    for vc in c:
        heapq.heappush(d, -(ve+vc))

for i in range(k):
    print((-heapq.heappop(d)))
# Original solution
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc123_d
import itertools
import math

# input
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 = range(1000)
# B = range(1000)
# C = range(1000)
# getans
A = sorted(A, reverse=True)
B = sorted(B, reverse=True)
C = sorted(C, reverse=True)
arr = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if i*j*k > K:
                break
            arr.append(A[i]+B[j]+C[k])
#print(len(arr))
arr = sorted(arr, reverse=True)[:K]
# output
ans = '\n'.join(map(str, arr))
print(ans)


# Optimized solution
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc123_d
import itertools
import math

# input
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 = range(1000)
# B = range(1000)
# C = range(1000)
# getans
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
arr = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            arr.append(A[i]+B[j]+C[k])
#print(len(arr))
arr.sort(reverse=True)
# output
ans = '\n'.join(map(str, arr[:K]))
print(ans)
# 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 range(X):
    for j in range(Y):
        AB.append(A[i] + B[j])
AB.sort(reverse=True)

ABC = []
for i in range(min(len(AB), K)):
    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 k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            ABC.append(A[i] + B[j] + C[k])

ABC.sort(reverse=True)
for i in range(K):
    print((ABC[i]))
# Original solution
#conding utf-8
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=[]
ans=[]
for i in range(len(a)):
  for j in range(len(b)):
    ab.append(a[i]+b[j])
    
ab.sort()
ab.reverse()
del ab[k:]

for i in range(len(ab)):
  for j in range(len(c)):
    ans.append(ab[i]+c[j])
    
ans.sort()
ans.reverse()

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

# Optimized solution
#conding utf-8
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=[]
ans=[]
for i in range(len(a)):
  for j in range(len(b)):
    ab.append(a[i]+b[j])
    
ab.sort()
ab.reverse()
del ab[k:]

c.sort()
c.reverse()

for i in range(len(ab)):
  for j in range(len(c)):
    ans.append(ab[i]+c[j])
    
ans.sort()
ans.reverse()

for i in range(k):
  print((ans[i]))
# Original solution
#conding utf-8
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=[]
ans=[]
for i in range(len(a)):
  for j in range(len(b)):
    ab.append(a[i]+b[j])
    
ab.sort()
ab.reverse()
del ab[k:]

c.sort()
c.reverse()

for i in range(len(ab)):
  for j in range(len(c)):
    ans.append(ab[i]+c[j])
    
ans.sort()
ans.reverse()

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

# Optimized solution
#conding utf-8
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.reverse()
b.reverse()
c.reverse()

ans=[]

for i in range(len(a)):
  for j in range(len(b)):
    if (i+1)*(j+1)>K:
      break
    for k in range(len(c)):
      if (i+1)*(j+1)*(k+1)>K:
        break
      ans.append(a[i]+b[j]+c[k])
    
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()))
import heapq
ans = []
heapq.heapify(ans)
for a in A:
    for b in B:
        for c in C:
          heapq.heappush(ans,-(a+b+c))
for _ in range(K):
    i = heapq.heappop(ans)
    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,B,Cのリストを降順にソート
A.sort(reverse =True)
B.sort(reverse =True)
C.sort(reverse =True)

# A,B,Cを上からp,q,r番目を選択した場合にp*q*rがKより大きい組み合わせがKより上位に来ることはない
# A,B,Cを上から参照していき。p*q*rがK以下の場合はリストにa+b+cを追加，K以上の場合はbreak
D = []
for p in range(1,X+1):
    for q in range(1,Y+1):
        for r in range(1,Z+1):
            if p*q*r<=K:
                D.append(A[p-1]+B[q-1]+C[r-1])
            else:
                break
D.sort(reverse=True)

for i in range(K):
    print((D[i]))
# Original solution
x,y,z,k = list(map(int,input().split()))	

al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al = sorted(al)
bl = sorted(bl)
cl = sorted(cl)
rank = []
for xx in range(x-1,-1,-1):
    tmp = al[xx]+bl[-1]+cl[-1]
    if len(rank) >= k:
        if rank[-1] >= tmp:
            break
    for yy in range(y-1, -1, -1):
        tmp = al[xx]+bl[yy]+cl[-1]
        if len(rank) >= k:
            if rank[-1] >= tmp:
                break
        for zz in range(z-1,-1,-1):
            if len(rank) < k:
                rank.append(al[xx]+bl[yy]+cl[zz])
                rank = sorted(rank, reverse=True)
            else:
                tmp = al[xx]+bl[yy]+cl[zz]
                if rank[-1] < tmp:
                    rank.pop()
                    rank.append(tmp)
                    rank = sorted(rank, reverse=True)
                else:
                    break

for i in rank:
    print(i)
                
            
            

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

al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al = sorted(al)
bl = sorted(bl)
cl = sorted(cl)
rank = []
flag = False
for xx in range(x-1,-1,-1):
    tmp = al[xx]+bl[-1]+cl[-1]
    if flag and rank[-1] >= tmp:
        break
    for yy in range(y-1, -1, -1):
        tmp = al[xx]+bl[yy]+cl[-1]
        if flag and rank[-1] >= tmp:
            break
        for zz in range(z-1,-1,-1):
            if len(rank) < k:
                rank.append(al[xx]+bl[yy]+cl[zz])
                rank = sorted(rank, reverse=True)
            else:
                tmp = al[xx]+bl[yy]+cl[zz]
                if rank[-1] < tmp:
                    flag = True
                    rank.pop()
                    rank.append(tmp)
                    rank = sorted(rank, reverse=True)
                else:
                    break

for i in rank:
    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()))

sumsofAandB = sorted([a+b for a in A for b in B])
sumsofAll = sorted([ab+c for ab in sumsofAandB for c in C], reverse=True)
for i in range(K):
    print((sumsofAll[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()))

sumsofAandB = sorted([a+b for a in A for b in B], reverse=True)[:K]
sumsofAll = sorted([ab+c for ab in sumsofAandB for c in C], reverse=True)
for i in range(K):
    print((sumsofAll[i]))
# Original solution
# -*- coding:utf-8 -*-

def solve():
    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 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 i in range(0, K):
        print((ans[i]))


if __name__ == "__main__":
    solve()


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


def solve():
    """ TLE """
    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 x in range(X):
        for y in range(Y):
            for z in range(Z):
                abc = A[x]+B[y]+C[z]
                if len(ans) < K-1:
                    ans.append(abc)
                    continue
                elif len(ans) == K-1:
                    ans.append(abc)
                    ans.sort(reverse=True)
                    continue
                
                if abc > ans[-1]:
                    ans[-1] = abc
                    ans.sort(reverse=True)
                    continue

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


if __name__ == "__main__":
    solve()