program main
      implicit none
      integer :: n, m, x
      integer, allocatable :: c(:), a(:,:), y(:), z(:)
      integer :: i, cnt
      integer(8) :: price, lowprice = 10**9
      logical, allocatable :: used(:)

      read *, n, m, x
      allocate( c(n) )
      allocate( a(n,m) )
      do i = 1, n
        read *, c(i), a(i,:)
      end do

      allocate( z(m) )
      allocate( y(n) )
      allocate( used(n) )
      y = 1
      used(:) = .false.
      call DFS(1,n)

      print *, lowprice

contains
recursive subroutine DFS(pos,v)
      implicit none
      integer, intent(in) :: pos,v
      integer :: i, k, j

      if( pos == v+1) then
      !   print *, y

         z(:) = 0
         cnt = 0
         price = 0
         do  k = 1, n
           price = price + c(y(k))
      !     print *, price
           do j = 1, m
             z(j) = z(j) + a(y(k),j)
             if ( z(j) >= x ) then
      !         print *, k, j, z(j),x
               cnt = cnt + 1
             end if
           end do

           if ( cnt == m ) then
             if ( lowprice >= price ) then
               lowprice = price
               exit
             end if
           end if

         end do

         if( cnt < m ) then
           print *, '-1'
           stop
         end if

         return
      end if

      do i = 1, v
        if ( .not. used(i) ) then
          y(pos) = i
          used(i) = .true.
          call DFS(pos+1,v)
          used(i) = .false.
        end if
      end do

end subroutine DFS      
end program main
