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

int N, M, K, a[2009], b[2009], c[2009], col[2009], cntw, A[2009][2009], ret[2009][4009], dp[2009][2009][2]; bool used[2009]; vector<pair<int, int>>x[2009]; vector<int>G[2009];

void dfs(int pos) {
	if (col[pos] != 0) return;
	col[pos] = cntw; G[cntw].push_back(pos);
	for (int i = 0; i < x[pos].size(); i++) dfs(x[pos][i].first);
}
void calc_1(int pos) {
	int id = -1;
	for (int i : G[pos]) { if (x[i].size() == 1)id = i; }
	int cx = id; used[cx] = true; vector<int>B;
	while (true) {
		int nex = -1, nex2 = 0; used[cx] = true;
		for (int i = 0; i < x[cx].size(); i++) {
			if (used[x[cx][i].first] == false) { nex = x[cx][i].first; nex2 = x[cx][i].second; }
		}
		if (nex == -1)break;
		B.push_back(nex2); cx = nex;
	}
	for (int i = 0; i <= G[pos].size(); i++) { for (int j = 0; j <= G[pos].size(); j++) { dp[i][j][0] = -(1 << 30); dp[i][j][1] = -(1 << 30); } }
	dp[0][0][0] = 0; dp[0][1][1] = 0;
	for (int i = 0; i < G[pos].size() - 1; i++) {
		for (int j = 0; j < G[pos].size(); j++) {
			dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][0]);
			dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], dp[i][j][0]);
			dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][1]);
			if (B[i] != 0) dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], dp[i][j][1] + B[i]);
		}
	}
	for (int i = 0; i <= G[pos].size(); i++) A[pos][i] = max(dp[G[pos].size() - 1][i][0], dp[G[pos].size() - 1][i][1]);
}
void calc_2(int pos) {
	int cx = G[pos][0]; used[cx] = true; vector<int>B;
	while (true) {
		int nex = -1, nex2 = 0; used[cx] = true;
		for (int i = 0; i < x[cx].size(); i++) {
			if (used[x[cx][i].first] == false) { nex = x[cx][i].first; nex2 = x[cx][i].second; }
			if (B.size() == G[pos].size() - 1 && x[cx][i].first == G[pos][0]) B.push_back(x[cx][i].second);
		}
		if (nex == -1)break;
		B.push_back(nex2); cx = nex;
	}
	for (int i = 0; i <= G[pos].size(); i++) { for (int j = 0; j <= G[pos].size(); j++) { dp[i][j][0] = -(1 << 30); dp[i][j][1] = -(1 << 30); } }
	dp[0][0][0] = 0;
	for (int i = 0; i < G[pos].size(); i++) {
		for (int j = 0; j < G[pos].size(); j++) {
			dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][0]);
			if (i != G[pos].size() - 1) dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], dp[i][j][0]);
			dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][1]);
			if (i != G[pos].size() - 1 && B[i] != 0) dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], dp[i][j][1] + B[i]);
		}
	}
	for (int i = 0; i <= G[pos].size(); i++) A[pos][i] = max(A[pos][i], dp[G[pos].size()][i][0]);

	for (int i = 0; i <= G[pos].size(); i++) { for (int j = 0; j <= G[pos].size(); j++) { dp[i][j][0] = -(1 << 30); dp[i][j][1] = -(1 << 30); } }
	dp[0][0][1] = 0;
	for (int i = 0; i < G[pos].size(); i++) {
		for (int j = 0; j < G[pos].size(); j++) {
			if (i != G[pos].size() - 1) dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][0]);
			dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], dp[i][j][0]);
			if (i != G[pos].size() - 1) dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][1]);
			if (B[i] != 0) dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], dp[i][j][1] + B[i]);
		}
	}
	for (int i = 0; i <= G[pos].size(); i++) A[pos][i] = max(A[pos][i], dp[G[pos].size()][i][1]);
}
void solve(int pos) {
	if (G[pos].size() == 1) {
		for (int i = 0; i <= G[pos].size(); i++) A[pos][i] = 0;
		return;
	}
	bool I = false;
	for (int i : G[pos]) {
		if (x[i].size() == 1)I = true;
	}
	if (I == true) calc_1(pos);
	if (I == false) calc_2(pos);
}

int main() {
	cin >> N >> M >> K;
	for (int i = 1; i <= M; i++) { cin >> a[i] >> b[i] >> c[i]; x[a[i]].push_back(make_pair(b[i], c[i])); x[b[i]].push_back(make_pair(a[i], c[i])); }
	for (int i = 1; i <= N; i++) { if (col[i] == 0) { cntw++; dfs(i); } }
	for (int i = 0; i < 2009; i++) { for (int j = 0; j < 2009; j++) { ret[i][j] = -(1 << 28); A[i][j] = -(1 << 30); } }
	for (int i = 1; i <= cntw; i++) solve(i);
	ret[0][0] = 0;
	for (int i = 0; i < cntw; i++) {
		for (int j = 0; j <= K; j++) {
			if (ret[i][j] == -(1 << 28)) continue;
			for (int k = 0; k <= G[i + 1].size(); k++) {
				ret[i + 1][j + k] = max(ret[i + 1][j + k], ret[i][j] + A[i + 1][k]);
			}
		}
	}
	if (ret[cntw][K] == -(1 << 28)) cout << "Impossible" << endl;
	else cout << ret[cntw][K] << endl;
	return 0;
}


Measured memory_bytes: 74384