#include <bits/stdc++.h>
using namespace std;
int n, k, t;
vector<pair<int, int> > p;
vector<int> a;
bool m[100], w[100];
vector<int> h;
void solve(int j, int res) {
  if (t == 0) return;
  if (j == k) {
    t--;
    if (t == 0) cout << res;
    return;
  }
  solve(j + 1, res);
  if (!m[p[j].first] && !w[p[j].second]) {
    m[p[j].first] = w[p[j].second] = p[j].first != 0;
    solve(j + 1, res + a[j]);
    m[p[j].first] = w[p[j].second] = false;
  }
}
int main() {
  cin >> n >> k >> t;
  for (int i = 0; i < k; i++) {
    int m, w, r;
    cin >> m >> w >> r;
    p.push_back(make_pair(m, w));
    a.push_back(r);
  }
  for (int i = 0; i < n * n - k; i++) {
    a.push_back(0);
    p.push_back(make_pair(0, 0));
  }
  k = n * n;
  for (int i = 0; i < k; i++)
    for (int j = i + 1; j < k; j++)
      if (a[i] < a[j]) {
        swap(a[i], a[j]);
        swap(p[i], p[j]);
      }
  solve(0, 0);
  return 0;
}
