program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32)::n,m,i,x,j,k,ans,cnt
    integer(int32), allocatable:: c(:), a(:,:),r(:)
    logical,allocatable:: buy(:)

    read*, n,m,x

    allocate(c(n), a(m,n), r(m))
    allocate(buy(n))

    do i=1,n
        read*, c(i), a(:,i)
    end do
    ans = 1000000000
    do i=0,2**n
        do j=1,n
            buy(j) = btest(i,j-1)
        end do
        r(:) = 0
        cnt=0
        do j=1,n
            if (buy(j))then
                r(:) = r(:) + a(:,j)
                cnt=cnt+c(j)
            end if
        end do
        if (minval(r) >= x) ans = min(ans,cnt)
    end do
    if (ans == 1000000000) ans=-1
    print'(i0)', ans
end program main