// ~~ icebear love attttt ~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebearat"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 2e5 + 5;
int n, m;
vector<ii> G[N];
ll dist[N][2][2];
void init(void) {
cin >> n >> m;
FOR(i, 1, m) {
int u, v, w;
cin >> u >> v >> w;
G[u].pb(mp(v, w));
G[v].pb(mp(u, w));
}
}
struct state {
int node, s1, s2;
ll dist;
bool operator > (const state &other) const {
return dist > other.dist;
}
};
void process(void) {
priority_queue<state, vector<state>, greater<state>> Q;
memset(dist, 0x3f, sizeof dist);
Q.push({1, 0, 0, 0});
dist[1][0][0] = 0;
while(!Q.empty()) {
auto T = Q.top(); Q.pop();
if (dist[T.node][T.s1][T.s2] != T.dist) continue;
for(ii x : G[T.node]) {
int v, w; tie(v, w) = x;
if (minimize(dist[v][T.s1][T.s2], T.dist + w))
Q.push({v, T.s1, T.s2, dist[v][T.s1][T.s2]});
if (T.s1 == false) {
if (minimize(dist[v][true][T.s2], T.dist))
Q.push({v, true, T.s2, dist[v][true][T.s2]});
}
if (T.s2 == false) {
if (minimize(dist[v][T.s1][true], T.dist + 2 * w))
Q.push({v, T.s1, true, dist[v][T.s1][true]});
}
if (T.s1 == false && T.s2 == false) {
if (minimize(dist[v][true][true], T.dist + w))
Q.push({v, true, true, dist[v][true][true]});
}
}
}
FOR(i, 2, n) cout << dist[i][1][1] << ' ';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}
Ly8gfn4gaWNlYmVhciBsb3ZlIGF0dHR0dCB+fgojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGxsOwp0eXBlZGVmIHBhaXI8aW50LCBpbnQ+IGlpOwp0eXBlZGVmIHBhaXI8aW50LCBpaT4gaWlpOwoKdGVtcGxhdGU8Y2xhc3MgVD4KICAgIGJvb2wgbWluaW1pemUoVCAmYSwgY29uc3QgVCAmYikgewogICAgICAgIGlmIChhID4gYikgcmV0dXJuIGEgPSBiLCB0cnVlOwogICAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KCnRlbXBsYXRlPGNsYXNzIFQ+CiAgICBib29sIG1heGltaXplKFQgJmEsIGNvbnN0IFQgJmIpIHsKICAgICAgICBpZiAoYSA8IGIpIHJldHVybiBhID0gYiwgdHJ1ZTsKICAgICAgICByZXR1cm4gZmFsc2U7CiAgICB9CgojZGVmaW5lIEZPUihpLGEsYikgZm9yKGludCBpPShhKTsgaTw9KGIpOyArK2kpCiNkZWZpbmUgRk9SUihpLGEsYikgZm9yKGludCBpPShhKTsgaT49KGIpOyAtLWkpCiNkZWZpbmUgUkVQKGksIG4pIGZvcihpbnQgaT0wOyBpPChuKTsgKytpKQojZGVmaW5lIFJFRChpLCBuKSBmb3IoaW50IGk9KG4pLTE7IGk+PTA7IC0taSkKI2RlZmluZSBNQVNLKGkpICgxTEwgPDwgKGkpKQojZGVmaW5lIEJJVChTLCBpKSAoKChTKSA+PiAoaSkpICYgMSkKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZm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Rpc3RbVC5ub2RlXVtULnMxXVtULnMyXSAhPSBULmRpc3QpIGNvbnRpbnVlOwogICAgICAgIGZvcihpaSB4IDogR1tULm5vZGVdKSB7CiAgICAgICAgICAgIGludCB2LCB3OyB0aWUodiwgdykgPSB4OwogICAgICAgICAgICBpZiAobWluaW1pemUoZGlzdFt2XVtULnMxXVtULnMyXSwgVC5kaXN0ICsgdykpCiAgICAgICAgICAgICAgICBRLnB1c2goe3YsIFQuczEsIFQuczIsIGRpc3Rbdl1bVC5zMV1bVC5zMl19KTsKICAgICAgICAgICAgaWYgKFQuczEgPT0gZmFsc2UpIHsKICAgICAgICAgICAgICAgIGlmIChtaW5pbWl6ZShkaXN0W3ZdW3RydWVdW1QuczJdLCBULmRpc3QpKQogICAgICAgICAgICAgICAgICAgIFEucHVzaCh7diwgdHJ1ZSwgVC5zMiwgZGlzdFt2XVt0cnVlXVtULnMyXX0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChULnMyID09IGZhbHNlKSB7CiAgICAgICAgICAgICAgICBpZiAobWluaW1pemUoZGlzdFt2XVtULnMxXVt0cnVlXSwgVC5kaXN0ICsgMiAqIHcpKQogICAgICAgICAgICAgICAgICAgIFEucHVzaCh7diwgVC5zMSwgdHJ1ZSwgZGlzdFt2XVtULnMxXVt0cnVlXX0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChULnMxID09IGZhbHNlICYmIFQuczIgPT0gZmFsc2UpIHsKICAgICAgICAgICAgICAgIGlmIChtaW5pbWl6ZShkaXN0W3ZdW3RydWVdW3RydWVdLCBULmRpc3QgKyB3KSkKICAgICAgICAgICAgICAgICAgICBRLnB1c2goe3YsIHRydWUsIHRydWUsIGRpc3Rbdl1bdHJ1ZV1bdHJ1ZV19KTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBGT1IoaSwgMiwgbikgY291dCA8PCBkaXN0W2ldWzFdWzFdIDw8ICcgJzsKfQoKaW50IG1haW4oKSB7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsgY291dC50aWUoMCk7CiAgICBpZiAoZm9wZW4odGFzayIuaW5wIiwgInIiKSkgewogICAgICAgIGZyZW9wZW4odGFzayIuaW5wIiwgInIiLCBzdGRpbik7CiAgICAgICAgZnJlb3Blbih0YXNrIi5vdXQiLCAidyIsIHN0ZG91dCk7CiAgICB9CiAgICBpbnQgdGMgPSAxOwovLyAgICBjaW4gPj4gdGM7CiAgICB3aGlsZSh0Yy0tKSB7CiAgICAgICAgaW5pdCgpOwogICAgICAgIHByb2Nlc3MoKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cgo=