program cake_123
  implicit none
  integer :: x, y, z, k, p, q, r, i
  integer(8) :: a(1000), b(1000), c(1000), d(106307)
  integer :: u, v, w
  a = 0_8
  b = 0_8
  c = 0_8
  d = 0_8
  read(*,*) x, y, z, k
  read(*,*) a(1:x)
  read(*,*) b(1:y)
  read(*,*) c(1:z)
  call merge_sort(x,a(1:x))
  call merge_sort(y,b(1:y))
  call merge_sort(z,c(1:z))
  i = 1
  do p = 1, x
    if (p.gt.k) exit
    do q = 1, y
      if (p*q.gt.k) exit
      do r = 1, z
        if (p*q*r.gt.k) exit
        d(i) = a(p)+b(q)+c(r)
        i = i + 1
      end do
    end do
  end do
  call merge_sort(106307,d)
  do i = 1, k
    write(*,'(i0)') d(i)
  end do
contains
  subroutine merge_sort(n,c)
    implicit none
    integer, intent(in)       :: n
    integer(8), intent(inout) :: c(n)
    integer                   :: num, gth, i, ubnd
    num = n
    gth = 1
    do while (num.gt.1)
      do i = 1, num/2
        ubnd = min(2*i*gth,n)
        call merge(c(2*(i-1)*gth+1:(2*i-1)*gth),c((2*i-1)*gth+1:ubnd))
      end do
      gth = 2*gth
      num = (num+1)/2
    end do
    return
  end subroutine merge_sort
  subroutine merge(c1,c2)
    implicit none
    integer(8), intent(inout) :: c1(:), c2(:)
    integer(8)                :: c(size(c1)+size(c2))
    integer                   :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1)
    n2 = size(c2)
    do while (i1.le.n1.and.i2.le.n2)
      if (c1(i1).ge.c2(i2)) then
        c(i1+i2-1) = c1(i1)
        i1 = i1+1
      else
        c(i1+i2-1) = c2(i2)
        i2 = i2+1
      end if
    end do
    if (i1.le.n1) then
      c(i1+i2-1:n1+n2) = c1(i1:n1)
    else if (i2.le.n2) then
      c(i1+i2-1:n1+n2) = c2(i2:n2)
    end if
    c1 = c(1:n1)
    c2 = c(n1+1:n1+n2)
    return
  end subroutine merge
end program cake_123