#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define x first
#define y second
#define p_all(arr) for(auto i:arr){cout<<i<<" ";}cout<<"\n";
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        vector<vector<pll> > a(n);
        for(int i=0;i<m;i++)
        {
            ll u,v,w;
            cin>>u>>v>>w;
            u--,v--;
            a[u].push_back({v,w});
            a[v].push_back({u,w});
        }
        vector<vector<ll> > dis(n,vector<ll> (4,INF));
        set<pair<ll,pair<int,int> > > s;
        dis[0][0]=0;
        s.insert({0,{0,0}});
        while(!s.empty())
        {
            auto temp=*s.begin();
            pll p=temp.y;
            ll wt=temp.x;
            s.erase(s.begin());
            if(dis[p.x][p.y]<wt)
            continue;
            for(auto v:a[p.x])
            {
                if(!((p.y)&(1<<0)))
                {
                    if(dis[v.x][(p.y)|1]>wt+2*v.y)
                    {
                        dis[v.x][(p.y)|1]=wt+2*v.y;
                        s.insert({dis[v.x][(p.y)|1],{v.x,(p.y)|(1<<0)}});
                    }
                }
                if(!((p.y)&(1<<1)))
                {
                    if(dis[v.x][(p.y)|2]>wt)
                    {
                        dis[v.x][(p.y)|2]=wt;
                        s.insert({dis[v.x][(p.y)|2],{v.x,(p.y)|(1<<1)}});
                    }
                }
                if(dis[v.x][p.y]>wt+v.y)
                {
                    dis[v.x][p.y]=wt+v.y;
                    s.insert({dis[v.x][p.y],{v.x,p.y}});
                }
                if(p.y==0)
                {
                    if(dis[v.x][3]>wt+v.y)
                    {
                        dis[v.x][3]=wt+v.y;
                    }
                }
            }
        }
        for(int i=1;i<n;i++)
        cout<<dis[i][3]<<" ";
        cout<<"\n";
    }
    return 0;
}