#include using namespace std; using graph = vector>>; int main() { int n, m, k; cin >> n >> m >> k; graph to(n); for (int i = 0; i < m; i++) { int u, v, c; cin >> u >> v >> c; u--; v--; to.at(u).emplace_back(v, c); to.at(v).emplace_back(u, c); } auto far = [&](int threshold) { vector d(n, k); deque> q; q.emplace_front(0, 0); while (not q.empty()) { auto [v, d0] = q.front(); q.pop_front(); if (d.at(v) <= d0) { continue; } d.at(v) = d0; for (auto &&[next, cost] : to.at(v)) { int c = cost >= threshold; if (d.at(next) <= d0 + c) { continue; } if (c) { q.emplace_back(next, d0 + c); } else { q.emplace_front(next, d0); } } } return d.at(n - 1) >= k; }; int l = 0, r = 200001; while (r - l > 1) { int mid = (l + r) / 2; if (far(mid)) { l = mid; } else { r = mid; } } cout << l << endl; return 0; }