Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = inpl()
B = inpl()
C = sorted(inpl(), reverse=True)

AB = sorted([a+b for a in A for b in B])[-K:]
ans = [-1] * K

for c in C:
    if ans[0] > AB[-1] * c:
        break
    tmp = [ab + c for ab in AB][-K:]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")


Fixed submission:
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl(), reverse=True)

AB = [-1] * K
for a in A[::-1]:
    if AB[0] >= B[-1] + a:
        break
    tmp = [a + b for b in B[bisect(B, AB[0]-a):]][-K:]
    AB = list(merge(tmp, AB))[-K:]

ans = [-1] * K

for c in C:
    if ans[0] >= AB[-1] + c:
        break
    tmp = [ab + c for ab in AB[bisect(AB, ans[0]-c):]][-K:]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = inpl()
B = inpl()
C = sorted(inpl(), reverse=True)

AB = sorted([a+b for a in A for b in B])[-K:]
ans = [-1] * K

for c in C:
    if ans[0] > AB[-1] * c:
        break
    tmp = [ab + c for ab in AB]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")

Fixed submission:
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl(), reverse=True)

AB = [-1] * K
for a in A[::-1]:
    if AB[0] >= B[-1] + a:
        break
    tmp = [a + b for b in B[bisect(B, AB[0]-a):]][-K:]
    AB = list(merge(tmp, AB))[-K:]

ans = [-1] * K

for c in C:
    if ans[0] >= AB[-1] + c:
        break
    tmp = [ab + c for ab in AB[bisect(AB, ans[0]-c):]][-K:]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = inpl()
B = inpl()
C = sorted(inpl(), reverse=True)

AB = sorted([a+b for a in A for b in B])[-K:]
ans = [-1] * K

for c in C:
    if ans[0] > AB[-1] * c:
        break
    tmp = [ab + c for ab in AB]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")

Fixed submission:
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl(), reverse=True)

AB = [-1] * K
for a in A[::-1]:
    if AB[0] >= B[-1] + a:
        break
    tmp = [a + b for b in B[bisect(B, AB[0]-a):]][-K:]
    AB = list(merge(tmp, AB))[-K:]

ans = [-1] * K

for c in C:
    if ans[0] >= AB[-1] + c:
        break
    tmp = [ab + c for ab in AB[bisect(AB, ans[0]-c):]][-K:]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")