#include <bits/stdc++.h>
using namespace std;
struct elem {
  int x, y, lsize, wh_size, l, r;
  elem(int nx) : x(nx), y(rand()), lsize(0), wh_size(1), l(-1), r(-1) {}
};
vector<elem> ans;
int root = -1;
void split(int x, int cur, int &l, int &r) {
  if (cur == -1) {
    l = r = -1;
    return;
  }
  if (ans[cur].x >= x) {
    split(x, ans[cur].l, l, ans[cur].l);
    if (l != -1) {
      ans[cur].lsize -= ans[l].wh_size;
      ans[cur].wh_size -= ans[l].wh_size;
    }
    r = cur;
  } else {
    split(x, ans[cur].r, ans[cur].r, r);
    if (r != -1) ans[cur].wh_size -= ans[r].wh_size;
    l = cur;
  }
}
int merge(int l, int r) {
  if (l == -1 || r == -1) return max(l, r);
  if (ans[l].x > ans[r].x) swap(l, r);
  if (ans[l].y > ans[r].y) {
    ans[r].lsize += ans[l].wh_size;
    ans[r].wh_size += ans[l].wh_size;
    ans[r].l = merge(l, ans[r].l);
    if (root == l) root = r;
    return r;
  } else {
    ans[l].wh_size += ans[r].wh_size;
    ans[l].r = merge(ans[l].r, r);
    if (root == r) root = l;
    return l;
  }
}
void add(int x) {
  if (root == -1) {
    ans.push_back(elem(x));
    root = 0;
    return;
  }
  int l, r;
  split(x, root, l, r);
  ans.push_back(elem(x));
  merge(merge(l, ans.size() - 1), r);
}
struct engage {
  int wife, husband, cheer;
  engage() {}
  engage(int q, int w, int e) : husband(q - 1), wife(w - 1), cheer(e) {}
};
bool operator<(const engage &a, const engage &b) {
  return a.cheer == b.cheer ? (a.husband == b.husband ? a.wife < b.wife
                                                      : a.husband < b.husband)
                            : a.cheer > b.cheer;
}
int n, k, t, tth = -1;
vector<engage> a;
vector<bool> was_h, was_w;
int get_tth() {
  int cur = root, lsize = 0;
  while (cur != -1 && lsize < t - 1)
    if (lsize + ans[cur].lsize < t - 1) {
      lsize += ans[cur].lsize + 1;
      cur = ans[cur].r;
    } else if (lsize + ans[cur].lsize > t - 1)
      cur = ans[cur].l;
    else
      break;
  return cur != -1 ? ans[cur].x : -1;
}
void perebor(int cur = 0, const int ccheer = 0) {
  if (ans.size() >= t && ccheer > tth) return;
  if (cur >= k) {
    add(ccheer);
    if (ans.size() >= t) tth = get_tth();
    return;
  }
  perebor(cur + 1, ccheer);
  if (!was_h[a[cur].husband] && !was_w[a[cur].wife]) {
    was_h[a[cur].husband] = was_w[a[cur].wife] = true;
    perebor(cur + 1, ccheer + a[cur].cheer);
    was_h[a[cur].husband] = was_w[a[cur].wife] = false;
  }
}
int main() {
  scanf("%d%d%d", &n, &k, &t);
  a.resize(n);
  was_h.resize(n, false);
  was_w.resize(n, false);
  for (int i = 0; i < k; i++) {
    int q, w, e;
    scanf("%d%d%d", &q, &w, &e);
    a.push_back(engage(q, w, e));
  }
  sort(a.begin(), a.end());
  perebor();
  printf("%d\n", tth);
  return 0;
}
