import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
//END OF TEMPLATE
size_t n,m,x;
long[] c;
long[][] a;

void main(){
    scan(n,m,x);
    foreach(i;0..n){
        auto tmp=scanarr!long;
        c~=tmp[0];
        a~=tmp[1..$];
    }
    long cheep=inf!long;
    foreach(i;0..m){
        cheep=min(cheep,dfs(i,0.repeat(m).array.to!(size_t[]),0));
    }
    cheep.writeln;
}

auto dfs(size_t num,size_t[] skill,long cost){
    auto skillt=m.iota.map!(i=>skill[i]+
            a[num][i]).array;
    if(skillt.filter!(s=>s<x).array.length==0){
        return cost+c[num];
    }
    else if(num==m-1)
        return -1;
    else{
        size_t cheep=inf!size_t;
        foreach(next;num+1..m){
            cheep=min(cheep,dfs(next,skillt,cost+c[num]));
        }
        return cheep;
    }
}
