#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct UnionFind {
  vector<int> data;
  UnionFind(){}
  UnionFind(int n):data(n, -1){}
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

struct edge {
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

using Graph = vector<vector<edge>>;

int N, M, K;
Graph graph;
vint num_edge;

int dp_all[2002];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M >> K;
  resz(graph, N);
  UnionFind uf(N);
  resz(num_edge, N);
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    graph[a].emplace_back(b, c);
    graph[b].emplace_back(a, c);
    int x = uf.find(a), y = uf.find(b);
    if(x != y) {
      num_edge[x] += num_edge[y]+1;
      uf.unite(x, y);
    } else {
      num_edge[x]++;
    }
  }

  vint roots;
  rep(i, N) if(uf.find(i) == i) roots.push_back(i);

  auto getEnd = [&](int u)->int{
    int p = -1;
    while(graph[u].size() > 1) {
      if(graph[u][0].to != p) {
	p = u;
	u = graph[u][0].to;
      } else {
	p = u;
	u = graph[u][1].to;
      }
    }
    return u;
  };

  function<void(int, int, int, vint&)> reorder = [&](int u, int p, int s, vint& vec) {
    //cout << u << " " << p << " " << s << endl;
    for(auto&& e : graph[u]) {
      if(e.to == p) continue;
      vec.push_back(e.cost);
      if(e.to == s) return;
      reorder(e.to, u, s, vec);
      break;
    }
  };

  fill(dp_all, dp_all+2002, -inf);
  dp_all[0] = 0;
  int sz_all = 0;
  for(int r : roots) {
    int sz = uf.size(r);
    vint vec, res;
    if(num_edge[r] == 0) {
      resz(res, 2, -inf);
      res[0] = res[1] = 0;
    } else if(num_edge[r] == sz) {
      reorder(r, -1, r, vec);
      int dp[2][2002][2][2];
      fill((int*)dp[0], (int*)dp[2], -inf);
      int (*curr)[2][2] = dp[0];
      int (*next)[2][2] = dp[1];
      curr[0][0][0] = curr[1][1][1] = 0;
      //cout << (int)vec.size() << " " << num_edge[r] << endl;
      assert((int)vec.size() == num_edge[r]);
      rep(i, sz-1) {
	rep(j, 2002) rep(k, 2) rep(l, 2) next[j][k][l] = -inf;
	rep(j, sz) rep(k, 2) {
	  chmax(next[j][k][0], max(curr[j][k][0], curr[j][k][1]));
	  if(i == sz-2 && k == 1) {
	    if(vec[i+1] != 0) {
	      if(curr[j][k][0] != -inf) chmax(next[j+1][k][1], curr[j][k][0]+vec[i+1]);
	      if(vec[i] != 0 && curr[j][k][1] != -inf) chmax(next[j+1][k][1], curr[j][k][1]+vec[i]+vec[i+1]);
	    }
	  } else {
	    chmax(next[j+1][k][1], curr[j][k][0]);
	    if(vec[i] != 0 && curr[j][k][1] != -inf) chmax(next[j+1][k][1], curr[j][k][1]+vec[i]);
	  }
	}
	swap(curr, next);
	//cout<<curr[K][0][0]<<" "<<curr[K][0][1]<<" "<<curr[K][1][0]<<" "<<curr[K][1][1]<<endl;
      }
      resz(res, sz+1, -inf);
      rep(i, sz+1) rep(j, 2) rep(k, 2) res[i] = max(res[i], curr[i][j][k]);
    } else if(num_edge[r] == sz-1) {
      reorder(getEnd(r), -1, -1, vec);
      int dp[2][2002][2];
      fill((int*)dp[0], (int*)dp[2], -inf);
      int (*curr)[2] = dp[0];
      int (*next)[2] = dp[1];
      curr[0][0] = curr[1][1] = 0;
      assert((int)vec.size() == num_edge[r]);
      rep(i, sz-1) {
	rep(j, 2002) rep(k, 2) next[j][k] = -inf;
	rep(j, sz) {
	  chmax(next[j][0], max(curr[j][0], curr[j][1]));
	  chmax(next[j+1][1], curr[j][0]);
	  if(vec[i] != 0 && curr[j][1] != -inf) chmax(next[j+1][1], curr[j][1]+vec[i]);
	}
	swap(curr, next);
      }
      resz(res, sz+1, -inf);
      rep(i, sz+1) res[i] = max(curr[i][0], curr[i][1]);
    } else {
      assert(false);
    }
    //cout<<r<<endl;
    for(int i = sz_all; i >= 0; i--) {
      //cout << i <<" " <<dp_all[i]<<endl;
      if(dp_all[i] == -inf) continue;
      for(int j = sz; j >= 0; j--) {
	if(res[j] == -inf) continue;
	chmax(dp_all[i+j], dp_all[i]+res[j]);
      }
    }
    sz_all += sz;
  }
  if(dp_all[K] == -inf) cout << "Impossible" << endl;
  else cout << dp_all[K] << endl;

  return 0;
}

Measured memory_bytes: 3620