Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

x,y,z,K=rl()
A=rl()
B=rl()
C=rl()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
X=[]
for a,b,c in zip(A,B,C):
    X.append([a,0])
    X.append([b,1])
    X.append([c,2])
X.sort(reverse=True)

ca=0
cb=0
cc=0
xl = len(X)
if x*y*z>=3000:
    for i in range(len(X)):
        _,a = X[i]
        if a == 0:
            ca += 1
        elif a == 1:
            cb += 1
        else:
            cc += 1 
        if ca*cb*cc>=3000:
            xl=i
            break
else:
    ca=x
    cb=y
    cc=z

ans = []
import itertools
for a,b,c in itertools.product(A[:ca],B,C):
    ans.append(a+b+c)
if ca < x:
    for a,b,c in itertools.product(A[ca:],B[:cb],C):
        ans.append(a+b+c)
    if cb < y:
        for a,b,c in itertools.product(A[ca:],B[cb:],C[:cc]):
            ans.append(a+b+c)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

X,Y,Z,K=rl()
A=rl()
B=rl()
C=rl()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = []
for a in range(1,X+1):
    for b in range(1,Y+1):
        for c in range(1,Z+1):
            if a*b*c<=K:
                ans.append(A[a-1]+B[b-1]+C[c-1])
            else:
                break
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

X,Y,Z,K=rl()
A=rl()
B=rl()
C=rl()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
X=[]
for a,b,c in zip(A,B,C):
    X.append([a,0])
    X.append([b,1])
    X.append([c,2])
X.sort(reverse=True)

ca=0
cb=0
cc=0
xl = 0
for i in range(len(X)):
    _,a = X[i]
    if a == 0:
        ca += 1
    elif a == 1:
        cb += 1
    else:
        cc += 1 
    if ca*cb*cc>=K:
        xl=i
Ax=[]
Bx=[]
Cx=[]
for x,a in X[:(xl+1)]:
    if a == 0:
        Ax.append(x)
    elif a == 1:
        Bx.append(x)
    else:
        Cx.append(x)

ans = []
import itertools
for a,b,c in itertools.product(Ax,Bx,Cx):
    ans.append(a+b+c)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

X,Y,Z,K=rl()
A=rl()
B=rl()
C=rl()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = []
for a in range(1,X+1):
    for b in range(1,Y+1):
        for c in range(1,Z+1):
            if a*b*c<=K:
                ans.append(A[a-1]+B[b-1]+C[c-1])
            else:
                break
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

X,Y,Z,K=rl()
A=rl()
B=rl()
C=rl()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
X=[]
for a,b,c in zip(A,B,C):
    X.append([a,0])
    X.append([b,1])
    X.append([c,2])
X.sort(reverse=True)

ca=0
cb=0
cc=0
xl = 0
for i in range(len(X)):
    _,a = X[i]
    if a == 0:
        ca += 1
    elif a == 1:
        cb += 1
    else:
        cc += 1 
    if ca*cb*cc>=K:
        xl=i
Ax=[]
Bx=[]
Cx=[]
for x,a in X:
    if a == 0:
        Ax.append(x)
    elif a == 1:
        Bx.append(x)
    else:
        Cx.append(x)

ans = []
import itertools
for a,b,c in itertools.product(Ax,Bx,Cx):
    ans.append(a+b+c)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

X,Y,Z,K=rl()
A=rl()
B=rl()
C=rl()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans = []
for a in range(1,X+1):
    for b in range(1,Y+1):
        for c in range(1,Z+1):
            if a*b*c<=K:
                ans.append(A[a-1]+B[b-1]+C[c-1])
            else:
                break
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])