#include<bits/stdc++.h> #define int long long usingnamespace std; constint INF = 1e18;
signedmain(){ ios::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> n >> m >> k; vector<vector<pair<int, int>>> e(n); for (int i = 0; i < m; i++) { int u, v, w; cin >> u >> v >> w; --u; --v; e[u].emplace_back(v, w); e[v].emplace_back(u, w); } k--; vector<int> p(k); for (int i = 0; i < k; i++) { p[i] = i; } vector<vector<int>> dp(n, vector<int>(1 << k, INF)); for (int i = 0; i < k; i++) { dp[p[i]][1 << i] = 0; } for (int s = 0; s < 1 << k; s++) { for (int i = 0; i < n; i++) { for (int t = s; t; --t &= s) { dp[i][s] = min(dp[i][s], dp[i][t] + dp[i][s ^ t]); } } vector<bool> vis(n); vector<int> dis(n); priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q; for (int i = 0; i < n; i++) { dis[i] = dp[i][s]; q.emplace(dp[i][s], i); } while (!q.empty()) { auto t = q.top(); q.pop(); int u = t.second; if (vis[u]) { continue; } vis[u] = 1; for (auto x : e[u]) { int v = x.first; int w = x.second; if (dis[v] > dis[u] + w) { dis[v] = dis[u] + w; q.emplace(dis[v], v); } } } for (int i = 0; i < n; i++) { dp[i][s] = dis[i]; } }
for (int i = k; i < n; i++) { cout << dp[i][(1 << k) - 1] << "\n"; } return0; }