Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

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)
b.sort(reverse=True)
c.sort(reverse=True)

A = 10 ** 9
B = 10 ** 6
C = 10 ** 3

ans = 0

h = []

s = [[[0 for _ in range(z+1)] for _ in range(y+1)] for _ in range(x+1)]

t = a[0] + b[0] + c[0]

s[0][0][0] = 1

heappush(h, - t * A)

for _ in range(k):
    temp = - heappop(h)
    r = temp % C
    temp //= C
    q = temp % C
    temp //= C
    p = temp % C
    print(temp // C)
    if p < x-1 and s[p+1][q][r] == 0:
        heappush(h, - ((a[p+1] + b[q] + c[r]) * A + (p+1) * B + q * C + r))
        s[p + 1][q][r] = 1
    if q < y-1 and s[p][q+1][r] == 0:
        heappush(h, - ((a[p] + b[q+1] + c[r]) * A + p * B + (q+1) * C + r))
        s[p][q + 1][r] = 1
    if r < z-1 and s[p][q][r+1] == 0:
        heappush(h, - ((a[p] + b[q] + c[r+1]) * A + p * B + q * C + r + 1))
        s[p][q][r + 1] = 1




Fixed submission:
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 = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

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

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

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)
b.sort(reverse=True)
c.sort(reverse=True)

A = 10 ** 9
B = 10 ** 6
C = 10 ** 3

ans = 0

h = []

s = [[[0 for _ in range(z+1)] for _ in range(y+1)] for _ in range(x+1)]

t = a[0] + b[0] + c[0]

s[0][0][0] = 1

heappush(h, - t * A)

for _ in range(k):
    temp = - heappop(h)
    r = temp % C
    temp //= C
    q = temp % C
    temp //= C
    p = temp % C
    print(temp // C)
    if p < x-1 and s[p+1][q][r] == 0:
        heappush(h, - ((a[p+1] + b[q] + c[r]) * A + (p+1) * B + q * C + r))
        s[p + 1][q][r] = 1
    if q < y-1 and s[p][q+1][r] == 0:
        heappush(h, - ((a[p] + b[q+1] + c[r]) * A + p * B + (q+1) * C + r))
        s[p][q + 1][r] = 1
    if r < z-1 and s[p][q][r+1] == 0:
        heappush(h, - ((a[p] + b[q] + c[r+1]) * A + p * B + q * C + r + 1))
        s[p][q][r + 1] = 1




Fixed submission:
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 = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

for i in range(k):
    print(ans[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 = list(map(int, input().split()))

ab = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

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


Fixed submission:
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 = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

for i in range(k):
    print(ans[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 = list(map(int, input().split()))

ab = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

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


Fixed submission:
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 = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

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