#include<bits/stdc++.h>
using namespace std;
using ll= int64_t;
const ll inf=1e18;
int main(){
ios::sync_with_stdio(false),cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<vector<pair<int,int>>>g(n);
	for(int i=0;i<m;++i){
		int u,v,w;
		cin>>u>>v>>w;
		--u,--v;
		g[u].push_back({v,w});
		g[v].push_back({u,w});
	}
	vector<ll> dis(4*n,inf);
	dis[0]=0;
	priority_queue<pair<ll,int> >h;
	h.push({-0LL,0});
	while(h.size()){
		auto[d,x]=h.top();
		d=-d;
		h.pop();
		if(d>dis[x]) continue;
		int u=x/4;
		int p=x/2%2;
		int q=x%2;
		for(auto [v,w]:g[u]){
			int y=v*4+p*2+q;
			if(dis[x]+w<dis[y]){
				dis[y]=dis[x]+w;
				h.emplace(-dis[y],y);
			}
			if(p==0&&dis[x]<dis[y+2]){
				dis[y+2]=dis[x];
				h.emplace(-dis[y+2],y+2);
			}
			if(q==0&&dis[x]+2*w<dis[y+1]){
				dis[y+1]=dis[x]+2*w;
				h.emplace(-dis[y+1],y+1);
			}
		}
	}
	for(int i=1;i<n;++i){
		cout<<min(dis[i*4],dis[i*4+3])<<" \n"[i==n-1];
	}
  return 0;
}
