//////////////////////////////////////
////       ABHINASH GIRI          ////
/////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define pr 4294967296   // 2^32
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define high 1000000001
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             -1e18
#define pinf              1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define e               1000000000
#define w(x)            int t; cin>>t; while(t--)
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define co(x) cout<<(x)<<"\n"
#define endl "\n"
typedef unsigned long int  ul;
typedef unsigned long long int ull;
typedef unsigned long long  int  li;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<long int> vl;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long int,long int>> vpl;
typedef vector<pair<long long int,long long int>> vpll;
typedef long long ll;
bool cmp(pair<ll,ll>a,pair<ll,ll>b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first>b.first;
}
int main() {
    std::chrono::time_point<std::chrono::high_resolution_clock> start_timer, end_timer;
    start_timer = std::chrono::high_resolution_clock::now();
    bool show_time = false;  //  change it to true when needed;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif

    /* Cook your Code  */
    fast;
    int n,m,x;
    cin>>n>>m>>x;
    vector<vector<int>>vec;
    vector<int>price;
    for (int i = 0; i <n ; ++i) {
        vector<int>know;
        for (int j = 0; j <=m ; ++j) {
            int l;
            cin>>l;
            if(j==0)
            {
                price.emplace_back(l);
            }else { know.emplace_back(l);}
        }
        vec.emplace_back(know);
    }
    vector<pair<ll,ll>> cost;
    for (ll k = 1; k <(1LL<<n) ; ++k) {
        ll p =0,max_val=0;
        vector<ll>v(m,0);
        for (ll i = 0; i <n ; ++i) {
            if(k&(1LL<<i))
            {
                p+=price[i];
                for (li j = 0; j <m ; ++j) {
                    v[j]+=vec[i][j];
                }
            }
        }
        for (int l = 0; l <m ; ++l)
        {
            if(v[l]>=x)
            {
                max_val++;
            }
            else
            { max_val=-1;break;}
        }
        if(max_val!=-1)
        {
            cost.emplace_back(make_pair(max_val,p));
        }

    }
    sort(cost.begin(),cost.end(),cmp);
//    for(auto i : cost)
//    {
//        cout<<i.first<<" "<<i.second<<endl;
//    }
    if(cost.empty())
    {
        cout<<-1<<endl;
    }
    else cout<<cost[0].second<<endl;


    end_timer = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_timer-start_timer).count();
    if(show_time)
    {cout << "\\nElapsed Time: " << elapsed_time << "ms\\n";}

    return 0;
}

Measured memory_bytes: 3708