program main
  integer :: N, M
  integer :: X
  integer,allocatable :: C(:), A(:, :)
  integer :: i,j
  integer :: out,tmp
  logical,allocatable :: switch(:)
  integer,allocatable :: test(:)
  
  read(*,*) N, M, X
  allocate(C(N))
  allocate(A(N, M))
  allocate(switch(N))
  allocate(test(M))
  do i = 1, N
     read(*,*) C(i), A(i, :)
  end do
  if (all(sum(A(:,:), dim = 1) >= X)) then
     out = sum(C)
     do i=0,2**n-1
        do j=1,n
           switch(j) = btest(i,j-1)
        end do
        do j = 1,M
           test(j) = sum(A(:,j), mask=switch)
        end do
        if ( all(test >= X) ) then
           tmp = sum(C(:), mask=switch)
           if (tmp < out) then
              out = tmp
           end if
        end if
     end do
      write(*,'(i0)') out
  else
     write(*,'(i0)') -1
  end if
contains

  
end program main
