Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
X,Y,Z,K=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とBのわのうちでかい順にK個
ABsum=[]
for i in A:
    for j in B:
        ABsum.append(i+j)
ABsum=sorted(list(ABsum),reverse=True)
sumu=[]
for i in range(min(K,X*Y)):
    for j in C:
        sumu.append(ABsum[i]+j)
sumu=sorted(list(sumu),reverse=True)
for i in range(K):
    print(sumu[i])

Fixed submission:
from collections import deque
X,Y,Z,K=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とBのわのうちでかい順にK個
ABsum=[]
for i in A:
    for j in B:
        ABsum.append(i+j)
ABsum=sorted(list(ABsum),reverse=True)
sumu=[]
for i in range(min(K,X*Y)):
    for j in C:
        sumu.append(ABsum[i]+j)
sumu=sorted(list(sumu),reverse=True)
for i in range(K):
    print(sumu[i])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
X,Y,Z,K=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とBのわのうちでかい順にK個
ABsum=deque()
for i in A:
    for j in B:
        ABsum.append(i+j)
ABsum=sorted(list(ABsum),reverse=True)
sumu=deque()
for i in range(min(K,X*Y)):
    for j in C:
        sumu.append(ABsum[i]+j)
sumu=sorted(list(sumu),reverse=True)
for i in range(K):
    print(sumu[i])

Fixed submission:
from collections import deque
X,Y,Z,K=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とBのわのうちでかい順にK個
ABsum=[]
for i in A:
    for j in B:
        ABsum.append(i+j)
ABsum=sorted(list(ABsum),reverse=True)
sumu=[]
for i in range(min(K,X*Y)):
    for j in C:
        sumu.append(ABsum[i]+j)
sumu=sorted(list(sumu),reverse=True)
for i in range(K):
    print(sumu[i])

Buggy python submission (verdict: Runtime Error):
import numpy as np
from collections import deque
import bisect

X,Y,Z,K=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)
Amax,Bmax,Cmax=(max(j) for j in [A,B,C])
Umami=Amax+Bmax+Cmax
Adif=[abs(i-Amax) for i in A]
Bdif=[abs(x-Bmax) for x in B]
Cdif=[abs(p-Cmax) for p in C]#AdifBdifCdifから1個ずつ選んだ和を小さい方から3000個
rank3000=100000000#暫定3000位のやつ
visited=np.zeros((1000,1000,1000),dtype="int")#Ai,Bj,Ckの行ったやつ
queue=deque()
queue.append([0,0,0])
ranking=[]
ranked=0#3000枠埋まったら1になる
Powerful=0
while queue and Powerful ==0:
    a,b,c = queue.popleft()
    for j, k ,l in ([1,0,0],[0,1,0],[0,0, 1]):
        new_a, new_b, new_c = a+j,b+k,c+l
        rankin=0
        if 0<=a<X and 0<=b<Y and 0<=c<Z and  visited[new_a][new_b][new_c]==0:
            visited[new_a][new_b][new_c]=1
            queue.append([new_a,new_b,new_c])
            if Adif[a]+Bdif[b]+Cdif[c]<rank3000:
                rankin+=1
                ranking.append(Adif[a]+Bdif[b]+Cdif[c])
                if ranked==0:
                    if len(ranking)==K:
                        ranked=1
                ranking.sort()
                if ranked==1:
                    ranking.pop(-1)
                    rank3000=ranking[-1]
            if rankin==0:
                Powerful=1
                break
print(ranking)

    
    

Fixed submission:
from collections import deque
X,Y,Z,K=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とBのわのうちでかい順にK個
ABsum=[]
for i in A:
    for j in B:
        ABsum.append(i+j)
ABsum=sorted(list(ABsum),reverse=True)
sumu=[]
for i in range(min(K,X*Y)):
    for j in C:
        sumu.append(ABsum[i]+j)
sumu=sorted(list(sumu),reverse=True)
for i in range(K):
    print(sumu[i])