#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
#include <string>
#include <string.h>
#include <map>
#include <locale>
#include <math.h>


#define frup(FRUP_I,FROM,TO) for(long FRUP_I=FROM;FRUP_I<=TO;FRUP_I++)
#define frdn(FRDN_I,FROM,TO) for(long FRDN_I=FROM;FRDN_I<TO;FRDN_I++)

#define pub(VALUE) push_back(VALUE)
#define pob() pop_back()
#define mp(FST,SEC) make_pair(FST,SEC)
#define len(STR) STR.length()

#define IN "input.txt"
#define OUT "output.txt"

#define refresh(ARRAY,TARGET,VALUE) frdn(DEFINED_I,0,TARGET)ARRAY[DEFINED_I]=VALUE
#define watch(VALUE) {cout<<#VALUE;printf("=");cout<<VALUE;printf("\n");}
#define stop exit(0)

using namespace std;

typedef pair<long,long> ll;

const long INF=(long)1e09;

struct node{
       long h,w,r;
       };

long n,m,j,k,ans=0,c,t,z,next=0;
vector<long>all,a(40,0);
set<long>hus,wiw;
vector<node>d;

bool comp(node a, node b){
 return a.r>b.r;
}

int main(){
  //  freopen(IN,"r",stdin);
  //  freopen(OUT,"w",stdout);
      scanf("%ld %ld %ld",&n,&k,&t); 
      node l;
      l.h=0;
      l.w=0;
      l.r=0;
       d.pub(l); 
       frup(i,1,k){
                   long x,y,z;
                    scanf("%ld %ld %ld",&x,&y,&z);
                      node l;
      l.h=x;
      l.w=y;
      l.r=z;
                    d.pub(l);
                   }  
 sort(d.begin()+1,d.end(),comp);                  
  while(true){
              hus.clear();
              wiw.clear();
               long res=0;
               bool f=1;
                frup(i,1,k)
                  if(a[i]>0){
                            if(hus.count(d[i].h)||wiw.count(d[i].w)){
                                                                 f=0;
                                                                 break;
                                                                 }
                              hus.insert(d[i].h);
                              wiw.insert(d[i].w);
                              res+=d[i].r;                                      
                            }
               if(f)next++;
               if(next==t){
                           cout<<res;
                           return 0;
                           }   
               a[k]++;
               z=k;
                while(z>0){
                           if(a[z]>1){
                                      a[z-1]++;
                                      a[z]=0;
                                      }
                             z--;         
                           }   
               if(a[0])break;                   
              }     
              cout<<0;                                            
return 0;
}       
