#include using namespace std; typedef long long ll; typedef pair pll; typedef tuple tl; ll inf=1000000000000000000; struct edge{ll len,ma,num;}; bool cmp(edge a,edge b){ if(a.len!=b.len)return a.len>n>>m; vector v[n+1]; for(ll i=0;i>a>>b>>c; v[a].push_back(make_pair(b,c)); v[b].push_back(make_pair(a,c)); } ll d[n+1],da[n+1]; fill(d,d+n+1,inf); fill(da,da+n+1,inf); priority_queue,greater> q; q.push(make_pair(0,1)); bool used[n+1]; fill(used,used+n+1,false); d[1]=0; while(q.size()>0){ pll p=q.top();q.pop(); ll pf=p.first,ps=p.second; if(used[ps])continue; used[ps]=true; for(ll i=0;idis+pf){ d[now]=dis+pf; q.push(make_pair(dis+pf,now)); } } } fill(used,used+n+1,false); priority_queue,greater> qq; qq.push(make_tuple(0,0,1)); da[1]=0; while(qq.size()>0){ tl t=qq.top();qq.pop(); ll tf=get<0>(t),ts=get<1>(t),tt=get<2>(t); if(used[tt])continue; used[tt]=true; //cout<u){ da[now]=u; qq.push(make_tuple(u,y,now)); } } } for(ll i=1;i<=n;i++)cout<