Buggy python submission (verdict: Runtime Error):
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)
E=[]
ans=[]
for i in range(X):
    for j in range(Y):
        E.append(A[i]+B[j])
for i in range(K):
    for j in range(K):
        ans.append(E[i]+C[j])
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()))
C.sort(reverse=True)
E=[]
ans=[]
for i in range(X):
    for j in range(Y):
        E.append(A[i]+B[j])
E.sort(reverse=True)
for i in range(min(K,len(E))):
    for j in range(min(K,Y)):
        ans.append(E[i]+C[j])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
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)

sum1 = []
sum2 = []
sum3 = []
for i in range(X):
    for j in range(Y):
        for k in range(10):
            sum1.append(A[i] + B[j] + C[k])
for i in range(X):
    for j in range(10):
        for k in range(Y):
            sum2.append(A[i] + B[j] + C[k])
for i in range(10):
    for j in range(Y):
        for k in range(Z):
            sum3.append(A[i] + B[j] + C[k])
sum1.sort(reverse=True)
sum2.sort(reverse=True)
sum3.sort(reverse=True)
if sum1<=sum2 and sum3<=sum2:
    for i in range(K):
        print(sum2[i])
elif sum2<=sum1 and sum3 <= sum1:
    for i in range(K):
        print(sum1[i])
else:
    for i in range(K):
        print(sum3[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()))
C.sort(reverse=True)
E=[]
ans=[]
for i in range(X):
    for j in range(Y):
        E.append(A[i]+B[j])
E.sort(reverse=True)
for i in range(min(K,len(E))):
    for j in range(min(K,Y)):
        ans.append(E[i]+C[j])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
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)

sum1 = []
sum2 = []
sum3 = []
for i in range(X):
    for j in range(Y):
        for k in range(10):
            sum1.append(A[i] + B[j] + C[k])
for i in range(X):
    for j in range(10):
        for k in range(Y):
            sum2.append(A[i] + B[j] + C[k])
for i in range(10):
    for j in range(Y):
        for k in range(Z):
            sum3.append(A[i] + B[j] + C[k])
sum1.sort(reverse=True)
sum2.sort(reverse=True)
sum3.sort(reverse=True)
if sum1<=sum2 and sum3<=sum2:
    for i in range(K):
        print(sum2[i])
elif sum2<=sum1 and sum3 <= sum1:
    for i in range(K):
        print(sum1[i])
else:
    for i in range(K):
        print(sum3[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()))
C.sort(reverse=True)
E=[]
ans=[]
for i in range(X):
    for j in range(Y):
        E.append(A[i]+B[j])
E.sort(reverse=True)
for i in range(min(K,len(E))):
    for j in range(min(K,Y)):
        ans.append(E[i]+C[j])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])