#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> m >> x; vector> g(n); rep(i,m){ int u,v,a,b; cin >> u >> v >> a >> b; u--; v--; g[u].push_back({v,a,b}); g[v].push_back({u,a,b}); } int ok = -1, ng = 1e9+1; while(ng-ok>1){ int md = (ok+ng)/2; vector dist(n,INFLL); dist[0] = 0; priority_queue pq; pq.push({0,0}); while(pq.size()){ ll d,now; tie(d,now) = pq.top(); pq.pop(); if(dist[now]