#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a vector dijkstra(Int s,vector > > & G){ const T INF = numeric_limits::max(); using P = pair; Int n=G.size(); vector d(n,INF); vector b(n,-1); priority_queue,greater

> q; d[s]=0; q.emplace(d[s],s); while(!q.empty()){ P p=q.top();q.pop(); Int v=p.second; if(d[v]d[v]+c){ d[u]=d[v]+c; b[u]=v; q.emplace(d[u],u); } } } return d; } struct FastIO{ FastIO(){ cin.tie(0); ios::sync_with_stdio(0); } }fastio_beet; //INSERT ABOVE HERE signed main(){ Int n,m; cin>>n>>m; using P = pair; vector > G(n*2); for(Int i=0;i>a>>b>>c; a--;b--; G[a].emplace_back(b,c); G[b].emplace_back(a,c); G[a+n].emplace_back(b+n,c); G[b+n].emplace_back(a+n,c); G[a].emplace_back(b+n,0); G[b].emplace_back(a+n,0); } for(Int i=0;i