! ビット全探索？
   program abc167c
      implicit none
      integer::n,m,x
      integer,allocatable,dimension(:)::c,got
      integer,allocatable,dimension(:,:)::a
      integer::i,j,k,l
      integer::candi_bit,cost,check,ans=10000000

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

         do i=0,2**n-1
            check=0
            candi_bit=i
            cost=0
            got=0

            do j=1,n

               if (and(candi_bit,1)==1) then
                  cost=cost+c(j)

                  do k=1,m
                     got(k)=got(k)+a(j,k)
                  end do

               end if

               candi_bit=candi_bit/2
            end do

            do l=1,m
               if (got(l)<x) check=1
            end do

            if (check==0 .and. ans>cost) ans=cost

         end do

         if (ans/=10000000) then
            print *, ans
         else
            print *, '-1'
         end if

   end program abc167c