Buggy python submission (verdict: Runtime Error):
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
import heapq
h=[]
chk=[0]*(X*Y*Z)
heapq.heappush(h,(-(A[0]+B[0]+C[0]),0,0,0))
for _ in range(K):
  ans,i,j,k=heapq.heappop(h)
  print(-ans)
  if i+1<X and chk[(i+1)*(Y*Z)+j*Z+k]==0:
    chk[(i+1)*(Y*Z)+j*Z+k]=1
    heapq.heappush(h,(-(A[i+1]+B[j]+C[k]),i+1,j,k))
  if j+1<Y and chk[i*(Y*Z)+(j+1)*Z+k]==0:
    chk[i*(Y*Z)+(j+1)*Z+k]=1
    heapq.heappush(h,(-(A[i]+B[j+1]+C[k]),i,j+1,k))
  if k+1<Z and chk[i*(Y*Z)+j*Z+k+1]==0:
    chk[i*(Y*Z)+j*Z+k+1]=1
    heapq.heappush(h,(-(A[i]+B[j]+C[k+1]),i,j,k+1))
  #print(h,chk)

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

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()))
if X<Y and X<Z:
  X,Z=Z,X
  A,C=C,A
elif Y<X and Y<Z:
  Y,Z=Z,Y
  B,C=C,Y
C=sorted(C,reverse=True)
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C[:K]],reverse=True)[:K]
for x in ABC:
  print(x)


Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

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()))
if X>Y and X>Z:
  X,Z=Z,X
  A,C=C,A
elif Y>X and Y>Z:
  Y,Z=Z,Y
  B,C=C,Y
C=sorted(C,reverse=True)
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C[:K]],reverse=True)[:K]
for x in ABC:
  print(x)


Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

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()))
if X>Y and X>Z:
  X,Z=Z,X
  A,C=C,A
elif Y>X and Y>Z:
  Y,Z=Z,Y
  B,C=C,Y
C=sorted(C,,reverse=True)
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C[:K]],reverse=True)[:K]
for x in ABC:
  print(x)

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
if X>Y and X>Z:
  X,Z=Z,X
  A,C=C,A
elif Y>X and Y>Z:
  Y,Z=Z,Y
  B,C=C,Y
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())),reverse=True)
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C[:K]],reverse=True)[:K]
for x in ABC:
  print(x)

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
if X>Y and X>Z:
  X,Z=Z,X
  A,C=C,A
elif Y>X and Y>Z:
  Y,Z=Z,Y
  B,C=C,Y
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C[:K]],reverse=True)[:K]
for x in ABC:
  print(x)

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
if X>Y and X>Z:
  X,Z=Z,X
  A,C=C,A
elif Y>X and Y>Z:
  Y,Z=Z,Y
  B,C=C,Y
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C],reverse=True)[:K]
for x in ABC:
  print(x)

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
if X<Y and X<Z:
  X,Z=Z,X
  A,C=C,A
elif Y<X and Y<Z:
  Y,Z=Z,Y
  B,C=C,Y
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C],reverse=True)[:K]
for x in ABC:
  print(x)

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

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()))
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C],reverse=True)[:K]
for x in ABC:
  print(x)

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
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
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)