Buggy python submission (verdict: Time Limit Exceeded):
#%%
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()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[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()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
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()))

L = []

for i in range(len(A)):
    for j in range(len(B)):
        L.append(A[i] + B[j])

L.sort(reverse=True)

ans_list = [0] * (10000000)

for i in range(min(K,len(L))):
    for j in range(len(C)):
        ans_list.append(L[i] + C[j])

ans_list.sort(reverse=True)


for i in range(K):
    print(ans_list[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()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
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()))

L = [0] * (1000000)

for i in range(len(A)):
    for j in range(len(B)):
        tmp = A[i] + B[j] 
        L[i*1000+j] = tmp

L.sort(reverse=True)

ans_list = [0] * (3000000)

for i in range(min(K,len(L))):
    for j in range(len(C)):
        tmp = L[i] + C[j]
        ans_list[i*1000+j] = tmp

ans_list.sort(reverse=True)


for i in range(K):
    print(ans_list[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()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
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()))

L = [0] * (4000000)

for i in range(len(A)):
    for j in range(len(B)):
        tmp = A[i] + B[j] 
        L[i*1000+j] = tmp

L.sort(reverse=True)

ans_list = [0] * (4000000)

for i in range(min(K,len(L))):
    for j in range(len(C)):
        tmp = L[i] + C[j]
        ans_list[i*1000+j] = tmp

ans_list.sort(reverse=True)


for i in range(K):
    print(ans_list[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()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
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()))

L = []

for i in range(len(A)):
    for j in range(len(B)):
        tmp = A[i] + B[j] 
        L.append(tmp)

L.sort(reverse=True)

ans_list =[]
for i in range(min(K,len(L))):
    for j in range(len(C)):
        tmp = L[i] + C[j]
        ans_list.append(tmp)

ans_list.sort(reverse=True)


for i in range(K):
    print(ans_list[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()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
B = list(map(int, input().split()))
B.sort(reverse=True)
C = list(map(int, input().split()))
C.sort(reverse=True)
 
L = []
 
for i in range(min(200,len(A))):
    for j in range(min(200,len(B))):
        for k in range(min(200,len(C))):
            tmp = A[i] + B[j] + C[k]
            L.append(tmp)
 
L.sort(reverse=True)
 
for i in range(K):
    print(L[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()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
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()))

L = []

for i in range(len(A)):
    for j in range(len(B)):
        for k in range(len(C)):
            tmp = A[i] + B[j] + C[k]
            L.append(tmp)

L.sort(reverse=True)

for i in range(K):
    print(L[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()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])