#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int inf = 1e9;

vector<int> weightvec(int v, vector<bool> &used, vector<vector<pair<int,int>>> &adj){
    int curr = v;
    int prev = -1;
    vector<int> res;
    while(1){
        int next=-1, cost;
        for(auto p: adj[curr]){
            if(p.first!=prev and !used[p.first]){
                next = p.first;
                cost = p.second;
            }
        }
        if(next == -1) break;
        used[next] = true;
        prev = curr;
        curr = next;
        res.push_back(cost);
    }
    return res;
}

vector<int> dp_cycle(vector<int> &a, bool cycle){
    int n = a.size();
    // dp[i][j][k] = (iノード選択、最初のノードを選ぶ、直前のノードを選ぶ)ときの最大値
    vector<vector<vector<int>>> def(n+1, vector<vector<int>>(2,  vector<int>(2, -inf)));
    auto dp = def;
    dp[0][0][0] = dp[1][1][1] = 0;
    for(int i=0; i<n-1; i++){
        auto ndp = def;
        for(int d=0; d<2; d++){
            for(int j=0; j<n; j++){
                ndp[j][d][0] = max({dp[j][d][0], dp[j][d][1]});
                if(d==1 and i==n-2 and cycle){
                    if(a[i+1]!=0 and dp[j][d][0]!=-inf){
                        ndp[j+1][d][1] = max(ndp[j+1][d][1], dp[j][d][0]+a[i+1]);
                    }
                    if(a[i+1]!=0 and a[i]!=0 and dp[j][d][1]!=-inf){
                        ndp[j+1][d][1] = max(ndp[j+1][d][1], dp[j][d][1]+a[i]+a[i+1]);
                    }
                }else{
                    ndp[j+1][d][1] = dp[j][d][0];
                    if(a[i]!=0 and dp[j][d][1]!=-inf){
                        ndp[j+1][d][1] = max(ndp[j+1][d][1], dp[j][d][1]+a[i]);
                    }
                }
            }
        }
        swap(dp, ndp);
    }
    vector<int> res(n+1);
    for(int i=0; i<n+1; i++){
        res[i] = max({dp[i][0][0], dp[i][0][1], dp[i][1][0], dp[i][1][1]});
    }
    return res;
}


int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<pair<int,int>>> adj(n);
    for(int i=0; i<m; i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        adj[a].emplace_back(b, c);
        adj[b].emplace_back(a, c);
    }
    int isolated = 0;
    vector<vector<int>> path, cycle;
    vector<bool> used(n, false);
    for(int i=0; i<n; i++){
        if(used[i]) continue;
        if(adj[i].size() == 0u){
            isolated++;
            used[i] = true;
        }else if(adj[i].size() == 1u){
            path.push_back(weightvec(i, used, adj));
            used[i] = true;
        }
    }
    for(int i=0; i<n; i++){
        if(used[i]) continue;
        cycle.push_back(weightvec(i, used, adj));
    }

    vector<vector<int>> dp_connected;
    for(auto &v: path){
        v.push_back(-inf);
        dp_connected.push_back(dp_cycle(v, false));
    }
    for(auto &v: cycle){
        dp_connected.push_back(dp_cycle(v, true));
    }
    vector<int> dp(n+1, -inf);
    dp[0] = 0;
    for(auto &v: dp_connected){
        vector<int> ndp(n+1, -inf);
        for(int i=0; i<=n; i++){
            for(int j=0; j<(int)v.size(); j++){
                if(i+j<=n and dp[i]!=-inf and v[j]!=-inf){
                    ndp[i+j] = max(ndp[i+j], dp[i]+v[j]);
                }
            }
        }
        swap(dp, ndp);
    }
    int ans = *max_element(dp.begin()+max(0, k -isolated), dp.begin()+k+1);
    if(ans == -inf){
        cout << "Impossible" << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3940