#include <bits/stdc++.h>
using namespace std;
struct edge {
  int left;
  int right;
  int value;
};
struct rec {
  int sum;
  int idx;
  int num;
  int flag;
};
struct cmp {
  bool operator()(rec x, rec y) { return x.sum > y.sum; }
};
bool cmp2(edge x, edge y) { return x.value < y.value; }
int main() {
  priority_queue<rec, vector<rec>, cmp> a;
  int n, m, k;
  edge e[200];
  int l[200005][21];
  int r[200005][21];
  int total = 0;
  int cnt = 1;
  int ans = -1;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    cin >> e[i].left >> e[i].right >> e[i].value;
  }
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j < 21; j++) {
      l[i][j] = 0;
      r[i][j] = 0;
    }
  }
  sort(e, e + m, cmp2);
  rec t0;
  t0.idx = 0;
  t0.sum = e[0].value;
  t0.num = 0;
  t0.flag = 1;
  a.push(t0);
  l[0][e[0].left] = 1;
  r[0][e[0].right] = 1;
  while (1) {
    if (a.empty()) {
      break;
    }
    if (total > 100000) {
      break;
    }
    rec t = a.top();
    a.pop();
    if (k == 1) {
      ans = 0;
      break;
    }
    if (t.flag == 1) {
      cnt = cnt + 1;
    }
    if (cnt == k) {
      ans = t.sum;
      break;
    }
    if (t.idx < m - 1) {
      rec t2;
      if ((l[t.num][e[t.idx + 1].left] == 0) &&
          (r[t.num][e[t.idx + 1].right] == 0)) {
        total = total + 1;
        for (int j = 0; j <= n; j++) {
          l[total][j] = l[t.num][j];
          r[total][j] = r[t.num][j];
        }
        l[total][e[t.idx + 1].left] = l[total][e[t.idx + 1].left] + 1;
        r[total][e[t.idx + 1].right] = r[total][e[t.idx + 1].right] + 1;
        t2.idx = t.idx + 1;
        t2.sum = t.sum + e[t.idx + 1].value;
        t2.num = total;
        int choose = 0;
        for (int h = 0; h <= n; h++) {
          if (l[t2.num][h] > 1 || r[t2.num][h] > 1) {
            choose = 1;
          }
        }
        if (choose == 0) {
          t2.flag = 1;
        } else {
          t2.flag = 0;
        }
        a.push(t2);
      } else {
        total = total + 1;
        for (int j = 0; j <= n; j++) {
          l[total][j] = l[t.num][j];
          r[total][j] = r[t.num][j];
        }
        l[total][e[t.idx + 1].left] = l[total][e[t.idx + 1].left] + 1;
        r[total][e[t.idx + 1].right] = r[total][e[t.idx + 1].right] + 1;
        t2.idx = t.idx + 1;
        t2.sum = t.sum + e[t.idx + 1].value;
        t2.num = total;
        t2.flag = 0;
        a.push(t2);
      }
      if (l[t.num][e[t.idx].left] > 0) {
        l[t.num][e[t.idx].left] = l[t.num][e[t.idx].left] - 1;
      }
      if (r[t.num][e[t.idx].right] > 0) {
        r[t.num][e[t.idx].right] = r[t.num][e[t.idx].right] - 1;
      }
      if ((l[t.num][e[t.idx + 1].left] == 0) &&
          (r[t.num][e[t.idx + 1].right] == 0)) {
        total = total + 1;
        for (int j = 1; j <= n; j++) {
          l[total][j] = l[t.num][j];
          r[total][j] = r[t.num][j];
        }
        l[total][e[t.idx + 1].left] = l[total][e[t.idx + 1].left] + 1;
        r[total][e[t.idx + 1].right] = r[total][e[t.idx + 1].right] + 1;
        t2.idx = t.idx + 1;
        t2.sum = t.sum + e[t.idx + 1].value - e[t.idx].value;
        t2.num = total;
        int choose = 0;
        for (int h = 0; h <= n; h++) {
          if (l[t2.num][h] > 1 || r[t2.num][h] > 1) {
            choose = 1;
          }
        }
        if (choose == 0) {
          t2.flag = 1;
        } else {
          t2.flag = 0;
        }
        a.push(t2);
      } else {
        total = total + 1;
        for (int j = 1; j <= n; j++) {
          l[total][j] = l[t.num][j];
          r[total][j] = r[t.num][j];
        }
        l[total][e[t.idx + 1].left] = l[total][e[t.idx + 1].left] + 1;
        r[total][e[t.idx + 1].right] = r[total][e[t.idx + 1].right] + 1;
        t2.idx = t.idx + 1;
        t2.sum = t.sum + e[t.idx + 1].value - e[t.idx].value;
        t2.num = total;
        t2.flag = 0;
        a.push(t2);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
