#include using namespace std; int main(){ int N, M, K; cin >> N >> M >> K; vector>> E(N); for (int i = 0; i < M; i++){ int u, v, c; cin >> u >> v >> c; u--; v--; E[u].push_back(make_pair(c, v)); E[v].push_back(make_pair(c, u)); } int tv = 200000, fv = -1; while (tv - fv > 1){ int mid = (tv + fv) / 2; vector d(N, -1); deque> dq; dq.push_back(make_pair(0, 0)); while (!dq.empty()){ int dd = dq.front().first; int v = dq.front().second; dq.pop_front(); if (d[v] == -1){ d[v] = dd; for (auto P : E[v]){ int w = P.second; if (P.first > mid){ dq.push_back(make_pair(dd + 1, w)); } else { dq.push_front(make_pair(dd, w)); } } } } if (d[N - 1] < K){ tv = mid; } else { fv = mid; } } cout << tv << endl; }