#include #define rep(i,n) for(int i=0;i ; const int INF = 1e9; const int MOD = 1000000007; int n = 100005,m = 200005; vector> graph(2*n,vector

()); vector dijkstra(ll start){ vector shortest(n); vector visited(n,false); priority_queue,vector>,greater>> pq; pq.push(make_pair(0,start)); while (!pq.empty()){ pair now = pq.top(); pq.pop(); ll cost,node; tie(cost,node) = now; if(visited[node]){ continue; }else{ shortest[node] = cost; visited[node] = true; for(pair next:graph[node]){ ll next_cost,next_node; tie(next_cost,next_node) = next; pq.push(make_pair(cost+next_cost,next_node)); } } } return shortest; } int main(){ cin >> n >> m; rep(i,m){ ll a,b,c; cin >> a >> b >> c; --a;--b; graph[a].push_back(P(c,b)); graph[a].push_back(P(0,b+n)); graph[b].push_back(P(c,a)); graph[b].push_back(P(0,a+n)); graph[a+n].push_back(P(c,b+n)); graph[b+n].push_back(P(c,a+n)); } vector dis = dijkstra(0); rep(i,n){ if(i==0) cout << 0 << '\n'; else cout << dis[i] + dis[i+n] << '\n'; } return 0; }