#include using namespace std; typedef long long ll; typedef vector vl; typedef vector vvl; typedef pair pl; typedef vector vp; #define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i) #define rep(i,n) fore(i,0,(n)-1) #define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i) #define rrep(i,n) rfore(i,0,(n)-1) #define all(x) (x).begin(),(x).end() const ll INF=1001001001; const ll LINF=1001001001001001001; const ll D4[]={0,1,0,-1,0}; const ll D8[]={0,1,1,0,-1,-1,1,-1,0}; template bool chmax(T &a,const T &b){if(a bool chmin(T &a,const T &b){if(b struct edge { int src, to; T cost; edge(int to, T cost) : src(-1), to(to), cost(cost) {} edge(int src, int to, T cost) : src(src), to(to), cost(cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; template< typename T > using Edges = vector< edge< T > >; template< typename T > using WeightedGraph = vector< Edges< T > >; using UnWeightedGraph = vector< vector< int > >; template< typename T > using Matrix = vector< vector< T > >; void solve(){ ll n,m;cin>>n>>m; WeightedGraph g(2*n); while(m--){ ll a,b,c;cin>>a>>b>>c; a--,b--; g[a].emplace_back(b,c); g[b].emplace_back(a,c); g[a].emplace_back(b+n,0); g[b].emplace_back(a+n,0); g[a+n].emplace_back(b+n,c); g[b+n].emplace_back(a+n,c); } vl d(2*n,LINF); d[0]=d[n]=0; priority_queue> pq; pq.push(pl(0,0)); while(!pq.empty()){ ll src,d1; tie(d1,src)=pq.top(); pq.pop(); if(d1>d[src])continue; for(auto &e:g[src]){ ll to=e.to,cost=e.cost; if(d[to]<=d1+cost)continue; d[to]=d1+cost; pq.push(pl(d1+cost,to)); } } rep(i,n)cout<<(d[i]+d[i+n])<