Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) + (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) + (j+1) + (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Fixed submission:
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) * (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) * (j+1) * (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) + (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) + (j+1) + (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Fixed submission:
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) * (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) * (j+1) * (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K break
    
    for j in range(Y):
        if (i+1) + (j+1) > K break
        
        for k in range(Z):
            if (i+1) + (j+1) + (k+1) > K break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Fixed submission:
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) * (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) * (j+1) * (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = [(0,0,0,a[0]+b[0]+c[0])]
unvisited = [[[True for i in range(X)] for j in range(Y)] for k in range(Z)]
unvisited[0][0][0] = False
for i in range(K):
    xt,yt,zt,pt = l.pop(0)
    print(pt)
    list_dx = [1,0,0]
    list_dy = [0,1,0]
    list_dz = [0,0,1]
    for j in range(3):
        dx = list_dx[j]
        dy = list_dy[j]
        dz = list_dz[j]
        if xt+dx<X and yt+dy<Y and zt+dz<Z and xt+yt+zt<=K-3 and unvisited[xt+dx][yt+dy][zt+dz]:
            l.append((xt+dx,yt+dy,zt+dz,a[xt+dx]+b[yt+dy]+c[zt+dz]))
            l.sort(key=lambda x:x[3], reverse=True)
            unvisited[xt+dx][yt+dy][zt+dz] = False

Fixed submission:
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) * (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) * (j+1) * (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = [(0,0,0,a[0]+b[0]+c[0])]
unvisited = [[[True for i in range(X)] for j in range(Y)] for k in range(Z)]
unvisited[0][0][0] = False
for i in range(K):
    xt,yt,zt,pt = l.pop(0)
    print(pt)
    list_dx = [1,0,0]
    list_dy = [0,1,0]
    list_dz = [0,0,1]
    for j in range(3):
        dx = list_dx[j]
        dy = list_dy[j]
        dz = list_dz[j]
        if xt+dx<X and yt+dy<Y and zt+dz<Z and unvisited[xt+dx][yt+dy][zt+dz]:
            l.append((xt+dx,yt+dy,zt+dz,a[xt+dx]+b[yt+dy]+c[zt+dz]))
            l.sort(key=lambda x:x[3], reverse=True)
            unvisited[xt+dx][yt+dy][zt+dz] = False

Fixed submission:
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) * (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) * (j+1) * (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = [(0,0,0,a[0]+b[0]+c[0])]
unvisited = [[[True for i in range(X)] for j in range(Y)] for k in range(Z)]
unvisited[0][0][0] = False
for i in range(K):
    xt,yt,zt,pt = l.pop(0)
    print(pt)
    list_dx = [1,0,0]
    list_dy = [0,1,0]
    list_dz = [0,0,1]
    for j in range(3):
        dx = list_dx[j]
        dy = list_dy[j]
        dz = list_dz[j]
        if xt+dx<X and yt+dy<Y and zt+dz<Z and unvisited[xt+dx][yt+dy][zt+dz]:
            l.append((xt+dx,yt+dy,zt+dz,a[xt+dx]+b[yt+dy]+c[zt+dz]))
            l.sort(key=lambda x:x[3], reverse=True)
            unvisited[xt+dx][yt+dy][zt+dz] = False

Fixed submission:
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) * (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) * (j+1) * (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])