Buggy python submission (verdict: Time Limit Exceeded):
import heapq

X,Y,Z,K = 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)

top = A[0]+B[0]+C[0]

flg = [[[0] * Z for _ in range(Y)] for _ in range(X)]
flg[0][0][0] = 1
q = []
heapq.heappush(q,[0,0,0,0])

cnt = 0

while cnt < K:
	d,a,b,c = heapq.heappop(q)
	print(top-d)
	cnt += 1

	if a+1 < X:
		if flg[a+1][b][c] == 0:
			flg[a+1][b][c] = 1
			heapq.heappush(q,[d+A[a]-A[a+1], a+1, b, c])
	if b+1 < Y:
		if flg[a][b+1][c] == 0:
			flg[a][b+1][c] = 1
			heapq.heappush(q,[d+B[b]-B[b+1], a, b+1, c])
	if c+1 < Z:
		if flg[a][b][c+1] == 0:
			flg[a][b][c+1] = 1
			heapq.heappush(q,[d+C[c]-C[c+1], a, b, c+1])



Fixed submission:
X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for i in range(X):
	for j in range(Y):
		AB.append(A[i]+B[j])

AB.sort(reverse = True)
AB = AB[:min(K,len(AB))]

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

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

X,Y,Z,K = 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)

top = A[0]+B[0]+C[0]

flg = [[[0] * Z for _ in range(Y)] for _ in range(X)]
flg[0][0][0] = 1
q = []
heapq.heappush(q,[0,0,0,0])

cnt = 0

while cnt < K:
	d,a,b,c = heapq.heappop(q)
	print(top-d)
	cnt += 1

	if a+1 < X:
		if flg[a+1][b][c] == 0:
			flg[a+1][b][c] = 1
			heapq.heappush(q,[d+A[a]-A[a+1], a+1, b, c])
	if b+1 < Y:
		if flg[a][b+1][c] == 0:
			flg[a][b+1][c] = 1
			heapq.heappush(q,[d+B[b]-B[b+1], a, b+1, c])
	if c+1 < Z:
		if flg[a][b][c+1] == 0:
			flg[a][b][c+1] = 1
			heapq.heappush(q,[d+C[c]-C[c+1], a, b, c+1])



Fixed submission:
X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for i in range(X):
	for j in range(Y):
		AB.append(A[i]+B[j])

AB.sort(reverse = True)
AB = AB[:min(K,len(AB))]

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

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for i in range(X):
	for j in range(Y):
		AB.append(A[i]+B[j])

AB.sort(reverse = True)
AB = AB[:min(K,len(AB))]

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

Fixed submission:
X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for i in range(X):
	for j in range(Y):
		AB.append(A[i]+B[j])

AB.sort(reverse = True)
AB = AB[:min(K,len(AB))]

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