Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = 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)

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort(reverse=True)
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)

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


Fixed submission:
x, y, z, k = 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)

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

abc = [ab[i] + c[j] for j in range(z) for i in range(len(ab))]

abc.sort(reverse=True)

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

Buggy python submission (verdict: Runtime Error):
import heapq
x, y, z, k = map(int, input().split())
n = [x, y, z]
if x*y*z < k:
    k = x*y*z

abc = []
for _ in range(3):
    *l, = sorted(map(int, input().split()), reverse=True)
    abc.append(l)

h = [[-(abc[0][0]+abc[1][0]+abc[2][0]), [0, 0, 0]]]
heapq.heapify(h)

index = [0, 0, 0]
se = h[:]

for _ in range(k):
    ans, iterate = heapq.heappop(h)
    print(-ans)

    for i in range(3):
        if n[i] <= iterate[i] + 1: continue

        iterate[i] += 1

        s = -(abc[0][iterate[0]]+abc[1][iterate[1]]+abc[2][iterate[2]])
        t = [s, iterate[:]]

        if t not in se:
            heapq.heappush(h, t)
            se.append(t)

        iterate[i] -= 1


Fixed submission:
x, y, z, k = 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)

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

abc = [ab[i] + c[j] for j in range(z) for i in range(len(ab))]

abc.sort(reverse=True)

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

Buggy python submission (verdict: Runtime Error):
import heapq
x, y, z, k = map(int, input().split())
n = [x, y, z]
if x*y*z < k:
    k = x*y*z

abc = []
for _ in range(3):
    *l, = sorted(map(int, input().split()), reverse=True)
    abc.append(l)

h = [[-(abc[0][0]+abc[1][0]+abc[2][0]), [0, 0, 0]]]
heapq.heapify(h)

index = [0, 0, 0]
se = h[:]

for _ in range(k):
    ans, iter = heapq.heappop(h)
    print(-ans)

    for i in range(3):
        iter[i] += 1
        if iter[i] < n[i]:
            s = -(abc[0][iter[0]]+abc[1][iter[1]]+abc[2][iter[2]])
            t = [s, iter[:]]

            if t not in se:
                heapq.heappush(h, t)
                se.append(t)

        iter[i] -= 1


Fixed submission:
x, y, z, k = 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)

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

abc = [ab[i] + c[j] for j in range(z) for i in range(len(ab))]

abc.sort(reverse=True)

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

Buggy python submission (verdict: Runtime Error):
import heapq
x, y, z, k = map(int, input().split())
n = [x, y, z]
abc = []
for _ in range(3):
    *l, = sorted(map(int, input().split()), reverse=True)
    abc.append(l)

h = [[-(abc[0][0]+abc[1][0]+abc[2][0]), [0, 0, 0]]]
heapq.heapify(h)

index = [0, 0, 0]
se = h[:]

for _ in range(k):
    ans, iter = heapq.heappop(h)
    print(-ans)

    for i in range(3):
        iter[i] += 1
        if iter[i] < n[i]:
            s = -(abc[0][iter[0]]+abc[1][iter[1]]+abc[2][iter[2]])
            t = [s, iter[:]]

            if t not in se:
                heapq.heappush(h, t)
                se.append(t)

        iter[i] -= 1



Fixed submission:
x, y, z, k = 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)

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

abc = [ab[i] + c[j] for j in range(z) for i in range(len(ab))]

abc.sort(reverse=True)

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