#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  os << "{";
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
  return os << "}";
}

[[maybe_unused]] constexpr ll MOD = 1e9 + 7;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

struct Edge {
  int to;
  ll cost;
  Edge(int to, ll cost) : to(to), cost(cost) {}
};

int main() {
  cin.tie(0)->sync_with_stdio(0);

  int n, m;
  cin >> n >> m;
  vector<vector<Edge>> g(n);
  rep(i, 0, m) {
    int u, v;
    ll c;
    cin >> u >> v >> c;
    --u, --v;
    g[u].emplace_back(v, c);
    g[v].emplace_back(u, c);
  }

  vector<vector<vector<ll>>> d(n, vector<vector<ll>>(2, vector<ll>(2, INFL)));
  d[0][0][0] = 0;

  priority_queue<tuple<ll, ll, ll, ll>> pq;
  pq.emplace(0, 0, 0, 0);
  while (pq.size()) {
    auto [c, v, a, b] = pq.top();
    c *= -1;
    pq.pop();
    if (d[v][a][b] < c) continue;
    for (auto [nv, nc] : g[v]) {
      if (a == 0 && d[nv][1][b] > d[v][a][b]) {
        d[nv][1][b] = d[v][a][b];
        pq.emplace(-d[nv][1][b], nv, 1, b);
      }
      if (b == 0 && d[nv][a][1] > d[v][a][b] + nc * 2) {
        d[nv][a][1] = d[v][a][b] + nc * 2;
        pq.emplace(-d[nv][a][1], nv, a, 1);
      }
      if (a == 0 && b == 0 && d[nv][1][1] > d[v][a][b] + nc) {
        d[nv][1][1] = d[v][a][b] + nc;
        pq.emplace(-d[nv][1][1], nv, 1, 1);
      }
      if (d[nv][a][b] > d[v][a][b] + nc) {
        d[nv][a][b] = d[v][a][b] + nc;
        pq.emplace(-d[nv][a][b], nv, a, b);
      }
    }
  }
  rep(i, 1, n) cout << d[i][1][1] << ' ';
  cout << '\n';

  return 0;
}