#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<int(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
constexpr int INF = 1000000000;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

struct Edge {
  int src, dest, weight;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
void add_edge(Graph &g, int src, int dest, int weight) {
  if (weight == 0) weight = -INF;
  g[src].push_back((Edge){src, dest, weight});
  g[dest].push_back((Edge){dest, src, weight});
}

pair<vector<int>, vector<int>> dfs(const Graph& g, vector<bool>& vis, int i, int k, int prev = -1, bool use = false) {
  vis[i] = true;
  for (auto e : g[i]) {
    if (e.dest == prev) continue;
    if (vis[e.dest]) { // cycle
      vector<int> res1(k+1, -INF);
      vector<int> res2(k+1, -INF);
      if (use) {
        res1[1] = e.weight; res2[0] = 0;
      } else {
        res1[1] = 0; res2[0] = 0;
      }
      return make_pair(res1, res2);
    }
    auto res = dfs(g, vis, e.dest, k, i, use);
    auto tmp = res.first;
    REP(j,k+1) {
      tmp[j] = max(tmp[j], res.second[j]);
    }
    vector<int> tmp2(k+1, -INF);
    REP(j,k) {
      if (res.first[j] > -INF && e.weight > -INF) {
        tmp2[j+1] = max(res.first[j] + e.weight, res.second[j]);
      } else {
        tmp2[j+1] = res.second[j];
      }
    }
    return make_pair(tmp2, tmp);
  }
  // leaf
  vector<int> res1(k+1, -INF);
  vector<int> res2(k+1, -INF);
  res1[1] = 0; res2[0] = 0;
  return make_pair(res1, res2);
}

int main() {
  int n,m,k;
  cin>>n>>m>>k;
  Graph g(n);
  UnionFind uf(n);
  set<int> mc;
  REP(i,m) {
    int a,b,c;
    cin>>a>>b>>c;
    --a;--b;
    add_edge(g, a, b, c);
    if (!uf.merge(a, b)) {
      mc.insert(a);
    }
  }
  if (m == 0) {
    cout << 0 << endl;
    return 0;
  }
  vector<bool> vis(n);
  vector<vector<int>> tables;
  int pc = 0;
  REP(i,n) {
    if(!vis[i]) {
      if (g[i].size() == 1) {
        auto res = dfs(g, vis, i, k);
        REP(j,k+1) res.first[j] = max(res.first[j], res.second[j]);
        tables.push_back(res.first);
      } else if (mc.count(i)) {
        auto tmp = vis;
        auto res = dfs(g, tmp, i, k, -1, true);
        auto res2 = dfs(g, vis, i, k, -1, false);
        REP(j,k+1) res.first[j] = max(res.first[j], res2.second[j]);
        tables.push_back(res.first);
      } else if (g[i].size() == 0) {
        ++pc;
      }
    }
  }
  int l = tables.size();
  auto res = tables[0];
  REP(i,l-1) {
    vector<int> tmp(k+1, -INF);
    REP(j,k+1) {
      REP(p,j+1) {
        if (res[p] > -INF && tables[i+1][j-p] > -INF) {
          tmp[j] = max(tmp[j], res[p] + tables[i+1][j-p]);
        }
      }
    }
    swap(tmp, res);
  }
  int ans = -INF;
  REP(i,pc+1) {
    if (i > k) break;
    ans = max(ans, res[k-i]);
  }
  if (ans <= -INF) {
    cout << "Impossible" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10996