program main
  implicit none
  integer(8) :: X,Y,Z,K
  integer:: tot, tot2
  integer(8),allocatable :: A(:),B(:),C(:)
  integer(8),allocatable :: AB(:),ABC(:)
  integer(8),allocatable :: AB2(:),C2(:)
  integer :: i1,i2,i3,i
  read(*,*) X,Y,Z,K
  allocate(A(X),B(Y),C(Z))
  read(*,*) A(:)
  read(*,*) B(:)
  read(*,*) C(:)

  allocate( AB(X*Y) )
  tot=X*Y
  i = 0
  do i1 = 1,X
     do i2 = 1,Y
           i = i + 1
           AB(i) = A(i1) + B(i2) 
     end do
  end do
  allocate(AB2(tot))
  call hsort(int(tot,8), AB)
  tot2 =(tot-max(tot-K,1) + 1)*Z
  allocate(ABC( tot2 ) )
  i=0
  do i1 = tot,max(tot-K,1),-1
     do i2 = 1,Z
        i = i + 1
        ABC(i) = AB(i1) + C(i2)
     end do
  end do
  call hsort(int(tot2,8), ABC)
  do i = 1,K
     write(*,'(i0)') ABC(tot2-i+1)
  end do
  stop
contains
  
  subroutine hsort(n, x)
    implicit none
    integer(8), intent(IN) :: n
    integer(8), intent(INOUT) :: x(n)
    ! local
    integer(8) k
    integer(8) :: tmp,tmp2
    ! external subroutine
    !external mkheap

    do k = n/2, 1, -1
       tmp = x(k)
       call mkheap(n, x, k, n, tmp)
    enddo

    do k = n, 2, -1
       tmp = x(k)
       x(k) = x(1)

       call mkheap(n, x, int(1,8), k-1, tmp)
    end do

    return
  end subroutine hsort

  subroutine mkheap(n, x, root, leaf, val)
    implicit none
    integer(8), intent(IN)    :: n, root, leaf
    integer(8), intent(INOUT) :: x(1:n)
    integer(8), intent(IN)    :: val
    ! local
    integer(8) :: i, j
    integer(8) :: tmp

    i = root
    j = i * 2

    do
       if (j > leaf) exit

       if (j < leaf) then
          if (x(j) < x(j+1)) j = j + 1
       end if

       if (x(j) > val) then
          x(i) = x(j)
          i = j
          j = i * 2
       else
          j = leaf + 1
       endif
    end do

    x(i) = val

    return
  end subroutine mkheap
  recursive function iqsort(ix) result(ires)
    integer(8), allocatable :: ires(:)
    integer(8), intent(in)  :: ix(:)
    integer(8) :: k
    if (size(ix) <= 1) then 
       ires = ix
    else  
       k = ix(size(ix) / 2)
       ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
    end if
  end function iqsort
end program main
