#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 2000

struct Edge{
	Edge(int arg_to,ll arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to;
	ll cost;
};

int N,E,K;
int in_num[NUM];
int group_index;
int group_min_in_num[NUM];
int boss[NUM],height[NUM];
int member_num[NUM];
bool calculated[NUM],visited[NUM];
ll work_dp[NUM+1][NUM+1][2][2]; //work_dp[何匹目か(k)][何匹選んだか][kを選んだか][最初のモンスターを選んだか] = 最大ポイント
ll max_value[NUM+1]; //あるグループから、任意の数を選ぶ際の最大ポイント
ll sequence[NUM]; //連結コストの数列
ll dp[2][NUM+1]; //大本のdp
vector<Edge> G[NUM];


int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		member_num[boss_x] += member_num[boss_y];
		boss[boss_y] = boss_x;


	}else if(height[x] < height[y]){

		member_num[boss_y] += member_num[boss_x];
		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		member_num[boss_x] += member_num[boss_y];
		boss[boss_y] = boss_x;
		height[x]++;
	}
}


void make_sequence(int group_id,int node_id,int pre_node,int index){

	if(index <= member_num[group_id]-2){ //最後の要素ではない

		for(int i = 0; i < G[node_id].size(); i++){
			if(G[node_id][i].to == pre_node)continue;

			sequence[index+1] = G[node_id][i].cost;

			make_sequence(group_id,G[node_id][i].to,node_id,index+1);
		}

	}else{ //グループの最後の要素

		for(int i = 0; i < G[node_id].size(); i++){
			if(G[node_id][i].to == pre_node)continue;

			if(group_min_in_num[group_id] == 2){ //輪
				sequence[0] = G[node_id][i].cost;
			}
		}
	}
}

void calc(int group_id){

	int max_index = member_num[group_id];

	for(int i = 0; i <= max_index; i++){
		max_value[i] = -BIG_NUM;
		for(int k = 0; k <= max_index; k++){
			for(int a = 0; a < 2; a++){
				for(int b = 0; b < 2; b++){
					work_dp[i][k][a][b] = -BIG_NUM; //work_dp[何匹目か(k)][何匹選んだか][kを選んだか][最初のモンスターを選んだか] = 最大ポイント
				}
			}
		}
	}


	work_dp[1][0][false][false] = 0;
	work_dp[1][1][true][true] = 0;
	max_value[0] = 0;
	max_value[1] = 0;

	for(int i = 1; i < max_index; i++){ //0オリジンの、何匹目か(テーブル上では+1する)

		if(i != max_index-1 || group_min_in_num[group_id] != 2){ //最後の要素ではない、または輪構造ではない
			for(int num = 0; num <= i; num++){ //今まで何匹選んだか
				for(int a = 0; a < 2; a++){ //モンスターi-1を選んだか
					for(int b = 0; b < 2; b++){ //最初のモンスターを選んだか

						if(work_dp[i][num][a][b] == -BIG_NUM)continue;

						//今回選ぶ
						if(a == 0 || sequence[i] != -BIG_NUM){ //前のモンスターを選んでいない、または前回のモンスターと今回のモンスターが不仲でない
							if(a == 0){ //モンスターi-1を選んでいない
								work_dp[i+1][num+1][true][b] = max(work_dp[i+1][num+1][true][b],work_dp[i][num][a][b]);
							}else{	//モンスターi-1を選んだ
								work_dp[i+1][num+1][true][b] = max(work_dp[i+1][num+1][true][b],work_dp[i][num][a][b]+sequence[i]);
							}
							max_value[num+1] = max(max_value[num+1],work_dp[i+1][num+1][true][b]);
						}
						//今回選ばない
						work_dp[i+1][num][false][b] = max(work_dp[i+1][num][false][b],work_dp[i][num][a][b]);
					}
				}
			}
		}else{ //円環構造でかつ最後の要素

			for(int num = 0; num <= i; num++){ //今まで何匹選んだか

				//加えられるか
				if(sequence[0] == -BIG_NUM){ //最後のモンスターと最初のモンスターが不仲である場合

					if(sequence[i] == -BIG_NUM){

						//最初のモンスターを加えておらず、かつi-1のモンスターも加えていない場合のみ、モンスターiを加えられる
						if(work_dp[i][num][false][false] != -BIG_NUM){
							work_dp[i+1][num+1][true][false] = max(work_dp[i+1][num+1][true][false],work_dp[i][num][false][false]);
							max_value[num+1] = max(max_value[num+1],work_dp[i+1][num+1][true][false]);
						}

					}else{ //i-1のモンスターの加入状況はどちらでも良い

						if(work_dp[i][num][true][false] != -BIG_NUM){
							max_value[num+1] = max(max_value[num+1],work_dp[i][num][true][false]+sequence[i]);
						}
						if(work_dp[i][num][false][false] != -BIG_NUM){
							max_value[num+1] = max(max_value[num+1],work_dp[i][num][false][false]);
						}
					}

				}else{ //最後と最初が友達

					if(sequence[i] == -BIG_NUM){

						//i-1のモンスターを加えていない場合のみ、モンスターiを加えられる。最初のモンスターはどちらでも良い

						if(work_dp[i][num][false][true] != -BIG_NUM){
							max_value[num+1] = max(max_value[num+1],work_dp[i][num][false][true]+sequence[0]); //最初あり
						}
						if(work_dp[i][num][false][false] != -BIG_NUM){
							max_value[num+1] = max(max_value[num+1],work_dp[i][num][false][false]); //最初なし
						}

					}else{ //i-1のモンスターの加入状況はどちらでも良い

						//i-1なし
						if(work_dp[i][num][false][true] != -BIG_NUM){
							max_value[num+1] = max(max_value[num+1],work_dp[i][num][false][true]+sequence[0]); //最初あり
						}
						if(work_dp[i][num][false][false] != -BIG_NUM){
							max_value[num+1] = max(max_value[num+1],work_dp[i][num][false][false]); //最初なし
						}

						//i-1あり
						if(work_dp[i][num][true][true] != -BIG_NUM){
							max_value[num+1] = max(max_value[num+1],work_dp[i][num][true][true]+sequence[i]+sequence[0]); //最初あり
						}
						if(work_dp[i][num][true][false] != -BIG_NUM){
							max_value[num+1] = max(max_value[num+1],work_dp[i][num][true][false]+sequence[i]); //最初なし
						}
					}
				}
			}
		}
	}
}


int main(){

	scanf("%d %d %d",&N,&E,&K);

	for(int i = 0; i < N; i++){
		in_num[i] = 0;
		boss[i] = i;
 		height[i] = 0;
 		member_num[i] = 1;
	}

	int from,to;
	ll cost;

	for(int loop = 0; loop < E; loop++){
		scanf("%d %d %lld",&from,&to,&cost);
		from--;
		to--;
		if(cost == 0){
			cost = -BIG_NUM; //★★不仲なら、隣接するはず(あるノードの、エッジの端点としての登場回数は最大2だから)★★
		}
		G[from].push_back(Edge(to,cost));
		G[to].push_back(Edge(from,cost));
		unite(from,to);
		in_num[from]++;
		in_num[to]++;
	}

	//グラフの構造を把握するため、グループ毎に最小の入次数を計算する
	for(int i = 0; i < N; i++)group_min_in_num[i] = BIG_NUM;

	int boss_id;
	for(int i = 0; i < N; i++){
		boss_id = get_boss(i);
		group_min_in_num[boss_id] = min(group_min_in_num[boss_id],in_num[i]);
	}

	for(int i = 0; i < N; i++){
		calculated[i] = false;
		visited[i] = false;
	}

	//大本dpの初期化
	int CURRENT = 0,NEXT = 1;

	for(int i = 0; i <= N; i++){
		dp[CURRENT][i] = -BIG_NUM;
		dp[NEXT][i] = -BIG_NUM;
	}

	dp[CURRENT][0] = 0;

	//グループを順番に処理する
	for(int i = 0; i < N; i++){
		boss_id = boss[i];
		if(calculated[boss_id])continue;

		if(group_min_in_num[boss_id] == 1 && in_num[i] == 2)continue; //グループが直線状で、端でないならSKIP

		sequence[0] = 0; //輪なら上書きする
		make_sequence(boss_id,i,-1,0); //コストの数列を作る

		calc(boss_id);

		for(int k = N; k >= 0; k--){
			for(int num = min(k,member_num[boss_id]); num >= 0; num--){
				if(dp[CURRENT][k-num] == -BIG_NUM || max_value[num] == -BIG_NUM)continue;
				dp[NEXT][k] = max(dp[NEXT][k],dp[CURRENT][k-num]+max_value[num]);
			}
		}

		calculated[boss_id] = true;
		swap(CURRENT,NEXT);
		for(int k = 0; k <= N; k++){
			dp[NEXT][k] = -BIG_NUM;
		}
	}

	if(dp[CURRENT][K] == -BIG_NUM){
		printf("Impossible\n");
	}else{
		printf("%lld\n",dp[CURRENT][K]);
	}


	return 0;
}



Measured memory_bytes: 128716