Buggy python submission (verdict: Time Limit Exceeded):

X,Y,Z,K = map(int,input().split())

Q = []
topK = []
dic = {}

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

Q.append([X-1,Y-1,Z-1])

while len(Q) > 0:

    now = Q.pop(0)

    if len(topK) < K:
        
        if ( now[0] , now[1] , now[2]) not in dic:
            dic[ ( now[0] , now[1] , now[2]) ] = 1
            topK.append( A[now[0]] + B[now[1]] + C[now[2]] )
            topK.sort()

        if now[0] != 0 : Q.append([ now[0]-1 , now[1] , now[2] ])
        if now[1] != 0 : Q.append([ now[0] , now[1]-1 , now[2] ])
        if now[2] != 0 : Q.append([ now[0] , now[1] , now[2]-1 ])    

    elif topK[0] < A[now[0]] + B[now[1]] + C[now[2]]:

        if ( now[0] , now[1] , now[2] ) not in dic:

            dic[ (now[0] , now[1] , now[2])] = 1
            #topK.append( A[now[0]] + B[now[1]] + C[now[2]] )
            del topK[0]
            topK.append(A[now[0]] + B[now[1]] + C[now[2]])
            topK.sort()

        if now[0] != 0 : Q.append([ now[0]-1 , now[1] , now[2] ])
        if now[1] != 0 : Q.append([ now[0] , now[1]-1 , now[2] ])
        if now[2] != 0 : Q.append([ now[0] , now[1] , now[2]-1 ])          

topK.sort()
#print (dic)

for i in range(K):

    print (topK[-1-i])


Fixed submission:

X,Y,Z,K = map(int,input().split())

Q = []
topK = []
dic = {}

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

Q.append([X-1,Y-1,Z-1])
dic[(X-1,Y-1,Z-1)] = 1

while len(Q) > 0:

    now = Q.pop(0)

    if len(topK) < K:
        
        #if ( now[0] , now[1] , now[2]) not in dic:
        #dic[ ( now[0] , now[1] , now[2]) ] = 1
        topK.append( A[now[0]] + B[now[1]] + C[now[2]] )
        topK.sort()
            
        if now[0] != 0 and (now[0]-1 , now[1] , now[2]) not in dic:
            Q.append([ now[0]-1 , now[1] , now[2] ])
            dic[( now[0]-1 , now[1] , now[2] )] = 1
        if now[1] != 0 and (now[0] , now[1]-1 , now[2]) not in dic:
            Q.append([ now[0] , now[1]-1 , now[2] ])
            dic[( now[0] , now[1]-1 , now[2] )] = 1
        if now[2] != 0 and (now[0] , now[1] , now[2]-1) not in dic:
            Q.append([ now[0] , now[1] , now[2]-1 ])
            dic[( now[0] , now[1] , now[2]-1 )] = 1


    elif topK[0] < A[now[0]] + B[now[1]] + C[now[2]]:

        #if ( now[0] , now[1] , now[2] ) not in dic:

        #dic[ (now[0] , now[1] , now[2])] = 1
            #topK.append( A[now[0]] + B[now[1]] + C[now[2]] )
        del topK[0]
        topK.append(A[now[0]] + B[now[1]] + C[now[2]])
        topK.sort()

        if now[0] != 0 and (now[0]-1 , now[1] , now[2]) not in dic:
            Q.append([ now[0]-1 , now[1] , now[2] ])
            dic[( now[0]-1 , now[1] , now[2] )] = 1
        if now[1] != 0 and (now[0] , now[1]-1 , now[2]) not in dic:
            Q.append([ now[0] , now[1]-1 , now[2] ])
            dic[( now[0] , now[1]-1 , now[2] )] = 1
        if now[2] != 0 and (now[0] , now[1] , now[2]-1) not in dic:
            Q.append([ now[0] , now[1] , now[2]-1 ])
            dic[( now[0] , now[1] , now[2]-1 )] = 1
     

topK.sort()
#print (dic)

for i in range(K):

    print (topK[-1-i])