#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18 + 7;
const long long MAXN = 2e5 + 7;
vector<pair<long long, long long>> g[MAXN];
long long a[MAXN];
long long dist[MAXN];
set<pair<long long, long long>> ms;
signed main() {
  ios_base::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    long long u, v, c;
    cin >> u >> v >> c;
    c *= 2;
    g[u - 1].push_back({v - 1, c});
    g[v - 1].push_back({u - 1, c});
  }
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    g[n].push_back({i, a[i]});
  }
  for (long long i = 0; i < MAXN; ++i) dist[i] = INF;
  dist[n] = 0;
  ms.insert({0, n});
  while (ms.size() != 0) {
    long long u = ms.begin()->second;
    ms.erase(ms.begin());
    for (pair<long long, long long> e : g[u]) {
      long long v = e.first;
      long long c = e.second;
      if (dist[u] + c < dist[v]) {
        ms.erase({dist[v], v});
        dist[v] = dist[u] + c;
        ms.insert({dist[v], v});
      }
    }
  }
  for (long long i = 0; i < n; ++i) {
    cout << dist[i] << ' ';
  }
  cout << '\n';
  return 0;
}
