#include "bits/stdc++.h"

using namespace std;

using i64 = long long;

const i64 MOD = i64(1e9) + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n, m, k;
    cin >> n >> m >> k;
    struct Edge{
        int to;
        int cost;
        Edge(int to, int cost) : to(to), cost(cost){}
    };
    vector<vector<Edge>> edges(n);
    for(int i = 0; i < m; ++i){
        int a, b;
        i64 c;
        cin >> a >> b >> c;
        --a, --b;
        if(c == 0)
            c = -MOD;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }

    bitset<2000> bs;

    vector<vector<vector<vector<int>>>> dp(n);

    vector<vector<int>> res;

    function<void(int,int,int)> f = [&](int x, int st, int cnt){
        bool fl = false;
        for(auto& ed : edges[x]){
            if(bs[ed.to])
                continue;
            bs.set(ed.to);
            if(dp[ed.to].empty())
                dp[ed.to].assign(n + 1, vector<vector<int>>(2, vector<int>(2, -MOD)));
            fl = true;

            for(int i = 0; i <= k; ++i){
                chmax(dp[ed.to][i][0][0], dp[x][i][0][0]);
                chmax(dp[ed.to][i][1][0], dp[x][i][1][0]);
                chmax(dp[ed.to][i][0][0], dp[x][i][0][1]);
                chmax(dp[ed.to][i][1][0], dp[x][i][1][1]);

                if(i != k){
                    chmax(dp[ed.to][i + 1][0][1], dp[x][i][0][0]);
                    chmax(dp[ed.to][i + 1][1][1], dp[x][i][1][0]);
                    chmax(dp[ed.to][i + 1][0][1], dp[x][i][0][1] + ed.cost);
                    chmax(dp[ed.to][i + 1][1][1], dp[x][i][1][1] + ed.cost);
                }
            }
            dp[x].clear();
            f(ed.to, st, cnt + 1);
        }
        if(!fl){
            vector<int> nex(cnt + 1, -MOD);
            for(auto& ed : edges[x]){
                if(ed.to == st && cnt > 2){
                    for(int i = 0; i <= cnt; ++i){
                        chmax(nex[i], dp[x][i][0][0]);
                        chmax(nex[i], dp[x][i][0][1]);
                        chmax(nex[i], dp[x][i][1][0]);
                        chmax(nex[i], dp[x][i][1][1] + ed.cost);
                    }
                    res.push_back(move(nex));
                    dp[x].clear();
                    return;
                }
            }
            for(int i = 0; i <= cnt; ++i){
                chmax(nex[i], dp[x][i][0][0]);
                chmax(nex[i], dp[x][i][0][1]);
                chmax(nex[i], dp[x][i][1][0]);
                chmax(nex[i], dp[x][i][1][1]);
            }
            res.push_back(move(nex));
            dp[x].clear();
            return;
        }
    };

    for(int i = 0; i < n; ++i){
        if(!bs[i] && edges[i].size() <= 1){
            if(dp[i].empty())
                dp[i].assign(n + 1, vector<vector<int>>(2, vector<int>(2, -MOD)));
            bs.set(i);
            dp[i][0][0][0] = 0;
            dp[i][1][1][1] = 0;
            f(i, i, 1);
        }
    }
    for(int i = 0; i < n; ++i){
        if(!bs[i]){
            if(dp[i].empty())
                dp[i].assign(n + 1, vector<vector<int>>(2, vector<int>(2, -MOD)));
            bs.set(i);
            dp[i][0][0][0] = 0;
            dp[i][1][1][1] = 0;
            f(i, i, 1);
        }
    }

    vector<int> ans(1, 0);
    for(auto& r : res){
        vector<int> nex(ans.size() + r.size() - 1, -MOD);
        for(int i = 0; i < ans.size(); ++i)
            for(int j = 0; j < r.size(); ++j)
                chmax(nex[i + j], ans[i] + r[j]);
        ans = move(nex);
    }

    if(ans[k] <= -1e8)
        cout << "Impossible" << endl;
    else
        cout << ans[k] << endl;

}



Measured memory_bytes: 97772