#include #include #include #include #include #include #include #include #include #include #include #define mkp make_pair #define mkt make_tuple #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; // const ll MOD = 998244353; template void chmin(T &a, const T &b) { if (a > b) a = b; } template void chmax(T &a, const T &b) { if (a < b) a = b; } const int INF = 1e9; const int LIM = 2e5 + 10; void solve() { int N, M, K; cin >> N >> M >> K; vector>> g(N); rep(i, M) { int a, b, c; cin >> a >> b >> c; a--; b--; g[a].emplace_back(b, c); g[b].emplace_back(a, c); } auto judge = [&](int lim) -> bool { deque DQ; vector dist(N, INF); DQ.push_front(0); dist[0] = 0; while (!DQ.empty()) { int now = DQ.front(); DQ.pop_front(); for (auto [to, w] : g[now]) { if (w >= lim) { if (dist[to] > dist[now] + 1) { dist[to] = dist[now] + 1; DQ.push_back(to); } } else { if (dist[to] > dist[now]) { dist[to] = dist[now]; DQ.push_front(to); } } } } if (dist[N - 1] >= K) return true; else return false; }; int up = LIM, dw = 0; while (abs(up - dw) > 1) { int mid = (up + dw) / 2; if (judge(mid)) dw = mid; else up = mid; } cout << dw << endl; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }