#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct {
    int c;
    int a[20];
}group_t;
int asc(const void* a, const void* b){
    group_t* x = (group_t*)a;
    group_t* y = (group_t*)b;
    if(x->c<y->c)return -1;
    else if(x->c==y->c)return 0;
    else return 1;
}
int main() {
    int n,m,x;scanf("%d%d%d",&n,&m,&x);
    group_t group[20];
    int ans =0;
    int sum[20]={};
    for(int i=0;i<n;i++){
        scanf("%d",&group[i].c);
        ans+=group[i].c;
        for(int j=0;j<m;j++){
            scanf("%d",&group[i].a[j]);
            sum[j]+=group[i].a[j];
        }
    }
    for(int i=0;i<m;i++){
        if(sum[i]<x){
            printf("-1\n");
            return 0;
        }
    }
    qsort(group, n, sizeof(group_t), asc);
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<m;j++){
            if(sum[j]-group[i].a[j] < x){
                goto END;
            }
        }
        for(int j=0;j<m;j++){
            sum[j]-=group[i].a[j];
        }
        ans-=group[i].c;
        END:;
    }

    
    printf("%d\n",ans);

 
}