#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int R = 100000007;

struct mar {
    int h, w, r;
};

int n, k, t;

vector <mar> g;
vector <int> ans (1, 0);
vector <vector <int>> curans;

void main () {
#ifndef ONLINE_JUDGE
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
#endif

    cin >> n >> k >> t;
    g.resize (k);
    for (int i = 0; i < k; ++i)
        cin >> g[i].h >> g[i].w >> g[i].r;
    curans.resize (k);
    for (int i = 0; i < k; ++i)
        curans[i].assign (1, g[i].r);
    for (int i = 0; i < k; ++i) {
        for (int j = i; j < k; ++j) {
            int cur = 0,
                cursum = 0,
                sz = curans[i].size();
            for (int x = 0; x < sz; ++x) {
                if (x - cursum == cur - 1)
                    cursum += cur++;
                bool sum = true;
                for (int y = i; y < cur + i + 1; ++y)
                    if (g[j].h == g[y].h || g[j].w == g[y].w) {
                        sum = false;
                        break;
                    }
                if (sum) curans[i].push_back(curans[i][x] + g[j].r);
            }
        }
    }
    for (int i = 0; i < k; ++i)
        ans.insert (ans.end(), curans[i].begin(), curans[i].end());
    sort (ans.begin(), ans.end());
    cout << ans[t-1];
}