#include <bits/stdc++.h>
using namespace std;
struct Trio {
  int m, w, r;
};
int a[200000] = {};
Trio b[2000] = {};
int Count = 0;
bool Comp(Trio q, Trio w) {
  if (q.r < w.r)
    return true;
  else
    return false;
}
int main() {
  int n, k, t;
  scanf("%d%d%d", &n, &k, &t);
  for (int i = 0; i < k; i++) scanf("%d%d%d", &b[i].m, &b[i].w, &b[i].r);
  sort(b, b + k, Comp);
  for (int i = 0; i < k; i++) a[i] = b[i].r;
  Count = k;
  for (int i = 0; i < k; i++)
    for (int j = i + 1; j < k; j++)
      if (b[i].m != b[j].m && b[i].w != b[j].w) a[Count++] = b[i].r + b[j].r;
  for (int i = 0; i < k; i++)
    for (int j = i + 1; j < k; j++)
      if (b[i].m != b[j].m && b[i].w != b[j].w)
        for (int z = j + 1; z < k; z++)
          if (b[z].m != b[j].m && b[z].w != b[j].w)
            a[Count++] = b[i].r + b[j].r + b[z].r;
  for (int i = 0; i < k; i++)
    for (int j = i + 1; j < k; j++)
      if (b[i].m != b[j].m && b[i].w != b[j].w)
        for (int z = j + 1; z < k; z++)
          if (b[z].m != b[j].m && b[z].w != b[j].w)
            for (int x = z + 1; x < k; x++)
              if (b[z].m != b[x].m && b[z].w != b[x].w)
                a[Count++] = b[i].r + b[j].r + b[z].r + b[x].r;
  for (int i = 0; i < k; i++)
    for (int j = i + 1; j < k; j++)
      if (b[i].m != b[j].m && b[i].w != b[j].w)
        for (int z = j + 1; z < k; z++)
          if (b[z].m != b[j].m && b[z].w != b[j].w)
            for (int x = z + 1; x < k; x++)
              if (b[z].m != b[x].m && b[z].w != b[x].w)
                for (int c = x + 1; c < k; c++)
                  if (b[c].m != b[x].m && b[c].w != b[x].w)
                    a[Count++] = b[i].r + b[j].r + b[z].r + b[x].r + b[c].r;
  sort(a, a + Count);
  if (t == 1)
    printf("0");
  else
    printf("%d", a[t - 2]);
  return 0;
}
