Buggy python submission (verdict: Time Limit Exceeded):
def solve(p):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(B)):
            for k in range(len(C)):
                if A[i] + B[j] + C[k] < p:
                    break
                cnt +=1
                if cnt >=k:
                    return True
    return False

def find(p):
    num = []
    for i in range(len(A)):
        for j in range(len(B)):
            for k in range(len(C)):
                if A[i] + B[j] + C[k] <= p:
                    break
                else:
                    num.append(A[i] + B[j] + C[k])
    return num

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)

max_taste = max(A) + max(B)+max(C)

M = max_taste
m = 0
n = (M+m) //2
while m!=n:
    if solve(n):
        M = n
    else:
        m = n
    n = (M+m) //2
    #print(M, m, n)
        
item = sorted(find(n), reverse=True)
if len(item) >=K:
    for i in range(K):
        print(item[i])
else:
    for i in range(len(item)):
        print(item[i])
    for _ in range(K- len(item)):
        print(n)

Fixed submission:
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)

sumAB = sorted([ai + bi for ai in a for bi in b],reverse=True)[:k]
final_ans = sorted([ci + abi for ci in c for abi in sumAB],reverse = True)[:k]

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

Buggy python submission (verdict: Time Limit Exceeded):
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)

ans = []
for ai in range(len(a)):
    for bi in range(len(b)):
        if (ai+1)*(bi+1) > k:
            continue
        for ci in range(len(c)):
            if (ai+1)*(bi+1)*(ci+1) >k:
                continue
            ans.append(a[ai] + b[bi] +c[ci])

ans = sorted(ans, reverse=True)
for i in range(k):
    print(ans[i])

Fixed submission:
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)

sumAB = sorted([ai + bi for ai in a for bi in b],reverse=True)[:k]
final_ans = sorted([ci + abi for ci in c for abi in sumAB],reverse = True)[:k]

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

Buggy python submission (verdict: Time Limit Exceeded):
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)

final_ans = sorted([a[ai] + b[bi] +c[ci] for ai in range(len(a)) for bi in range(len(b)) for ci in range(len(c)) if (ai+1)*(bi+1)*(ci+1) <=k],reverse=True)[:k]

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

Fixed submission:
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)

sumAB = sorted([ai + bi for ai in a for bi in b],reverse=True)[:k]
final_ans = sorted([ci + abi for ci in c for abi in sumAB],reverse = True)[:k]

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

Buggy python submission (verdict: Time Limit Exceeded):
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)

d = []
for i in range(len(a)):
    for j in range(len(b)):
        d.append(a[i]+b[j])

tmp = sorted(d, reverse=True)
if len(tmp) < k:
    use_tmp = tmp
else:
    use_tmp = tmp[0:k]
    
ans = []
for i in range(len(use_tmp)):
    for j in range(len(c)):
        ans.append(use_tmp[i]+c[j])
final_ans = sorted(ans, reverse=True)

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

Fixed submission:
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)

sumAB = sorted([ai + bi for ai in a for bi in b],reverse=True)[:k]
final_ans = sorted([ci + abi for ci in c for abi in sumAB],reverse = True)[:k]

for i in range(k):
    print(final_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()))

d = []
for i in range(len(a)):
    for j in range(len(b)):
        d.append(a[i]+b[j])
tmp = sorted(d, reverse=True)
if len(tmp) < k:
    use_tmp = tmp
else:
    use_tmp = tmp[0:k]
    
ans = []
for i in range(len(use_tmp)):
    for j in range(len(c)):
        ans.append(use_tmp[i]+c[j])
final_ans = sorted(ans, reverse=True)

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

Fixed submission:
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)

sumAB = sorted([ai + bi for ai in a for bi in b],reverse=True)[:k]
final_ans = sorted([ci + abi for ci in c for abi in sumAB],reverse = True)[:k]

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