#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n,m,k;cin>>n>>m>>k; vc v(n,vc(0)); rep(i,m){ int a,b,c;cin>>a>>b>>c; a--;b--; v[a].pb({b,c}); v[b].pb({a,c}); } ll wa=-1,ac=1e6; while(ac-wa>1){ int x=(ac+wa)/2; vcd(n,k+1); d[0]=0; dequeq; q.push_back(0); while(q.size()){ int a=q.front(); q.pop_front(); for(auto [au,c]:v[a]){ if(c>x)c=1; else c=0; if(d[au]<=d[a]+c)continue; d[au]=d[a]+c; if(c)q.push_back(au); else q.push_front(au); } } if(d[n-1]