#include <bits/stdc++.h>
using namespace std;
void check(int num, int p1, int p2, int p3, int p4, int p5) {}
int main(int argc, char **argv) {
  set<int> result;
  result.insert(0);
  int n;
  int k;
  int t;
  vector<pair<pair<int, int>, int> > all;
  cin >> n;
  cin >> k;
  cin >> t;
  int h;
  int w;
  int r;
  for (int i = 0; i < k; i++) {
    cin >> h;
    cin >> w;
    cin >> r;
    pair<int, int> p(h, w);
    pair<pair<int, int>, int> v(p, r);
    all.push_back(v);
  }
  vector<pair<pair<int, int>, int> >::iterator it;
  for (it = all.begin(); it < all.end(); it++) {
    pair<pair<int, int>, int> v = *it;
    result.insert(v.second);
  }
  for (int p1 = 0; p1 < k; p1++) {
    for (int p2 = 0; p2 < k; p2++) {
      for (int p3 = 0; p3 < k; p3++) {
        for (int p4 = 0; p4 < k; p4++) {
          for (int p5 = 0; p5 < k; p5++) {
            pair<int, int> pair_1 = all[p1].first;
            pair<int, int> pair_2 = all[p2].first;
            pair<int, int> pair_3 = all[p3].first;
            pair<int, int> pair_4 = all[p4].first;
            pair<int, int> pair_5 = all[p5].first;
            int rate = 0;
            if (n == 2) {
              if (((pair_1.first == pair_2.first) ||
                   (pair_1.second == pair_2.second))) {
                continue;
              }
              rate = all[p1].second + all[p2].second;
            }
            if (n == 3) {
              if (((pair_1.first == pair_2.first) ||
                   (pair_1.second == pair_2.second)) ||
                  ((pair_1.first == pair_3.first) ||
                   (pair_1.second == pair_3.second)) ||
                  ((pair_2.first == pair_3.first) ||
                   (pair_2.second == pair_3.second))) {
                continue;
              }
              rate = all[p1].second + all[p2].second + all[p3].second;
            }
            if (n == 4) {
              if (((pair_1.first == pair_2.first) ||
                   (pair_1.second == pair_2.second)) ||
                  ((pair_1.first == pair_3.first) ||
                   (pair_1.second == pair_3.second)) ||
                  ((pair_1.first == pair_4.first) ||
                   (pair_1.second == pair_4.second)) ||
                  ((pair_2.first == pair_3.first) ||
                   (pair_2.second == pair_3.second)) ||
                  ((pair_2.first == pair_4.first) ||
                   (pair_2.second == pair_4.second))) {
                continue;
              }
              rate = all[p1].second + all[p2].second + all[p3].second +
                     all[p4].second;
            }
            if (n == 5) {
              if (((pair_1.first == pair_2.first) ||
                   (pair_1.second == pair_2.second)) ||
                  ((pair_1.first == pair_3.first) ||
                   (pair_1.second == pair_3.second)) ||
                  ((pair_1.first == pair_4.first) ||
                   (pair_1.second == pair_4.second)) ||
                  ((pair_1.first == pair_5.first) ||
                   (pair_1.second == pair_5.second)) ||
                  ((pair_2.first == pair_3.first) ||
                   (pair_2.second == pair_3.second)) ||
                  ((pair_2.first == pair_4.first) ||
                   (pair_2.second == pair_4.second)) ||
                  ((pair_2.first == pair_5.first) ||
                   (pair_2.second == pair_5.second)) ||
                  ((pair_3.first == pair_4.first) ||
                   (pair_3.second == pair_4.second)) ||
                  ((pair_3.first == pair_5.first) ||
                   (pair_3.second == pair_5.second)) ||
                  ((pair_4.first == pair_5.first) ||
                   (pair_4.second == pair_5.second))) {
                continue;
              }
              rate = all[p1].second + all[p2].second + all[p3].second +
                     all[p4].second + all[p5].second;
            }
            result.insert(rate);
          }
        }
      }
    }
  }
  int cnt = 0;
  set<int>::iterator rez_it;
  for (rez_it = result.begin(); rez_it != result.end(); rez_it++) {
    cnt++;
    if (cnt == t) {
      cout << *rez_it;
    }
  }
  return 0;
}
