#include using namespace std; int main() { int n,m; long long x; cin>>n>>m>>x; vector>> g(n); for (int i=0;i>u>>v>>a>>b; u--; v--; g[u].push_back({v,a,b}); g[v].push_back({u,a,b}); } long long l=-1,r=1e10; while (r-l>1) { long long mid=(l+r)/2; vector dst(n,LLONG_MAX); dst[0]=0; priority_queue,vector>,greater>>pq; pq.push({0,0}); while (pq.size()) { auto [tmp,now]=pq.top(); pq.pop(); if (tmp>dst[now]) { continue; } for (auto [nxt,ngs,hb]:g[now]) { if (hbdst[nxt]) { continue; } dst[nxt]=dst[now]+ngs; pq.push({dst[nxt],nxt}); } } if (dst.back()<=x) { l=mid; } else { r=mid; } } cout<<(l<=0?-1:l)<