#include using namespace std; //#include //using namespace atcoder; using ll=long long; using Graph=vector>>; #define MAX 200003 #define MOD 1000000007 #define INF 1000000000000000000 int main(){ int N,M; cin>>N>>M; vector u(M),v(M); vector c(M),d(M); for(int i=0;i>u[i]>>v[i]>>c[i]>>d[i]; u[i]--; v[i]--; } Graph G(N); for(int i=0;i dist(N,INF); dist[0]=0; priority_queue,vector>,greater>> pq; pq.push(make_pair(dist[0],0)); while(!pq.empty()){ int v=pq.top().second; ll l=pq.top().first; pq.pop(); if(l>dist[v]){ continue; } for(auto p:G[v]){ int nv=p.first; int e=p.second; if(dist[v]+c[e] used(M,false); while(x!=0){ for(auto p:G[x]){ int nv=p.first; int e=p.second; if(dist[x]==dist[nv]+c[e]){ x=nv; used[e]=true; break; } } } ll ans=dist[N-1]; for(int i=0;idist[v]){ continue; } for(auto p:G[v]){ int nv=p.first; int e=p.second; if(used[e]==true){ if(dist[v]+d[e]