#include <bits/stdc++.h>
#define inf (long long)(1e10)
using namespace std;

struct edge {
  long long to, c;
};

long long n, m, k;
vector<vector<edge>> g;
vector<bool> ch;

void solve();
vector<long long> calc(const vector<long long> &memo, const long long &len,
                       long long last = 0);
vector<long long> mergeres(vector<long long> &now, vector<long long> &tmp);

int main() {
  cin >> n >> m >> k;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    if (c == 0) c = -inf;
    g[--a].push_back({--b, c});
    g[b].push_back({a, c});
  }
  solve();
  return 0;
}

void solve() {
  vector<long long> res(1, 0);
  ch.assign(n, 0);
  for (int i = 0; i < n; ++i)
    if (g[i].empty()) {
      res.push_back(0);
      ch[i] = 1;
    }
  // tree pattern
  for (int i = 0; i < n; ++i)
    if (g[i].size() == 1 && !ch[i]) {
      ch[i] = 1;
      vector<long long> memo(1, 0);
      long long now = i;
      while (1) {
        bool flg = 1;
        for (auto e : g[now])
          if (!ch[e.to]) {
            memo.push_back(e.c);
            now = e.to;
            ch[e.to] = 1;
            flg = 0;
            break;
          }
        if (flg) break;
      }
      long long len = memo.size();
      vector<long long> tmp = calc(memo, len);
      res = mergeres(res, tmp);
    }
  // circle pattern
  for (int i = 0; i < n; ++i)
    if (g[i].size() == 2 && !ch[i]) {
      ch[i] = 1;
      vector<long long> memo(1, 0), tmpuse, tmpnouse;
      long long st = i, now = i, last = g[i][1].c;
      while (1) {
        bool flg = 1;
        for (auto e : g[now])
          if (!ch[e.to]) {
            memo.push_back(e.c);
            now = e.to;
            ch[e.to] = 1;
            flg = 0;
            break;
          }
        if (flg) break;
      }
      long long len = memo.size();
      tmpuse = calc(memo, len, last);
      for (int i = 1; i < len - 1; ++i) memo[i] = memo[i + 1];
      memo.pop_back();
      tmpnouse = calc(memo, --len);
      len = tmpnouse.size();
      for (int i = 0; i < len; ++i) tmpuse[i] = max(tmpuse[i], tmpnouse[i]);
      res = mergeres(res, tmpuse);
    }
  if (res.size() < k + 1 || res[k] < (long long)(-1e9))
    cout << "Impossible" << endl;
  else
    cout << res[k] << endl;
}

vector<long long> calc(const vector<long long> &memo, const long long &len,
                       long long last) {
  vector<vector<vector<long long>>> dp(
      2, vector<vector<long long>>(len + 1, vector<long long>(2, -inf)));
  bool flg = last != 0;
  dp[flg][flg][flg] = 0;
  for (int i = flg; i < len; ++i)
    for (int j = 0; j <= len; ++j) {
      dp[(i + 1) & 1][j][0] = max(dp[i & 1][j][0], dp[i & 1][j][1]);
      if (j > 0)
        dp[(i + 1) & 1][j][1] =
            max(dp[i & 1][j - 1][0] + (i == len - 1) * last,
                dp[i & 1][j - 1][1] + memo[i] + (i == len - 1) * last);
    }
  vector<long long> res(len + 1, -inf);
  for (int i = 0; i <= len; ++i)
    res[i] = max(dp[len & 1][i][0], dp[len & 1][i][1]);
  return res;
}

vector<long long> mergeres(vector<long long> &now, vector<long long> &tmp) {
  int nowlen = now.size(), tmplen = tmp.size();
  vector<long long> res(nowlen + tmplen - 1, -inf);
  now[0] = tmp[0] = now[1] = tmp[1] = 0;
  for (int i = 0; i < nowlen; ++i) res[i] = max(res[i], now[i]);
  for (int i = 0; i < tmplen; ++i) res[i] = max(res[i], tmp[i]);
  for (int i = 0; i < nowlen; ++i)
    for (int j = 0; j < tmplen; ++j)
      res[i + j] = max(res[i + j], now[i] + tmp[j]);
  return res;
}


Measured memory_bytes: 3412