Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = list(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)

ans = []

for j in range(X):
    flag2 = 0
    for k in range(Y):
        flag = 0
        for l in range(Z):
            if j*k*l+1 <= K:
                ans.append(A[j]+B[k]+C[l])
            else: 
                if l == 0:
                    flag = 1
                break
        if k == 0 and flag == 1:
            flag2 = 1
            break
    if flag2 == 1:
        break


ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
X,Y,Z,K = list(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)

ans = []

for j in range(X):
    if j+1 > K:
        break
    for k in range(Y):
        if j*k+1 > K:
            break
        for l in range(Z):
            if j*k*l+1 <= K:
                ans.append(A[j]+B[k]+C[l])
            else: 
                break
                
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = list(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)

N = min(X,Y,Z)
ans = []
SUM = []
for i in range(N):
    SUM.append(A[i]+B[i]+C[i])

for i in range(N):
    ans = []
    for j in range(X):
        flag2 = 0
        for k in range(Y):
            flag = 0
            for l in range(Z):
                if A[j]+B[k]+C[l] >= SUM[i]:
                    ans.append(A[j]+B[k]+C[l])
                else: 
                    if l == 0:
                        flag = 1
                    break
            if k == 0 and flag == 1:
                flag2 = 1
                break
        if flag2 == 1:
            break
    if len(ans) >= K:
        break

ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
X,Y,Z,K = list(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)

ans = []

for j in range(X):
    if j+1 > K:
        break
    for k in range(Y):
        if j*k+1 > K:
            break
        for l in range(Z):
            if j*k*l+1 <= K:
                ans.append(A[j]+B[k]+C[l])
            else: 
                break
                
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = list(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)

N = min(X,Y,Z)
ans = []
SUM = []
for i in range(N):
    SUM.append(A[i]+B[i]+C[i])

for i in range(N):

    for j in range(X):
        flag2 = 0
        for k in range(Y):
            flag = 0
            for l in range(Z):
                if A[j]+B[k]+C[l] <= SUM[i]:
                    ans.append(A[j]+B[k]+C[l])
                elif l == 0:
                    flag = 1
                    break
            if k == 0 and flag == 1:
                flag2 = 1
                break
        if flag2 == 1:
            break
    if len(ans) >= K:
        break

ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
X,Y,Z,K = list(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)

ans = []

for j in range(X):
    if j+1 > K:
        break
    for k in range(Y):
        if j*k+1 > K:
            break
        for l in range(Z):
            if j*k*l+1 <= K:
                ans.append(A[j]+B[k]+C[l])
            else: 
                break
                
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])