'use strict';

const pipe=Symbol();

Function.prototype[pipe]=function(nextFunc){
  const that=this;
  return function(I){
    return nextFunc(that(I));
  }
}

function pre0(input){
  return input.
  split(/\n|\r/).
  map(
    str=>str.split(/\s+/).
    map(x=>x-0)
  );
}

function pre1(Arr){
  const NMX=Arr.shift();
  return [NMX,Arr];
}

String.prototype.zeroFill=function(N){
  return (new Array(N-this.length)).
  fill('0').
  join('')+this;
}

function choice(N,num){
  return num.
  toString(2).
  zeroFill(N).
  split('').
  map(x=>x-0);
}

function test(I,c){
  const [N,M,X]=I[0];
  const Arr=I[1];
  const testCase=new Array(M+1).fill(0);
  Arr.forEach(function(arr,i){
    if(c[i])
      arr.forEach(function(x,j){
        testCase[j]+=x;
      });
  });
  //console.log(c,testCase);
  const cost=testCase.shift();
  const safe=testCase.
  reduce(
    (acc,crr)=>Boolean(acc&&(crr>=X)),
    true
  );
  return safe?cost:Infinity;
}

function testAll(I){
  const N=I[0][0];
  const nmax=Math.pow(2,N);
  
  const choices=new Array(nmax).
  fill(0).
  map((z,i)=>choice(N,i));
  
  const cost=choices.
  reduce(
    (acc,crr,ind)=>Math.min(acc,test(I,crr)),
    Infinity
  );
  return cost;
}

function result(cost){
  console.log(isFinite(cost)?cost:-1);
}


pre0[pipe](
  pre1
)[pipe](
  testAll
)[pipe](
  result
)(require('fs').readFileSync('/dev/stdin','utf8'));
