#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
long long n, m, a, u, v, w, d[200010];
vector<vector<pair<long long, long long> > > g;
set<pair<long long, long long> > se;
void solve() {
  se.insert({0, n + 1});
  while (!se.empty()) {
    pair<int, int> now = *se.begin();
    se.erase(se.begin());
    long long v = now.second;
    for (long long i = 0; i < g[v].size(); i++) {
      long long len = g[v][i].second, to = g[v][i].first;
      if (d[v] + len < d[to]) {
        se.erase({d[to], to});
        d[to] = d[v] + len;
        se.insert({d[to], to});
      }
    }
  }
}
int main() {
  cin >> n >> m;
  g.resize(n + 2);
  for (long long i = 0; i < m; i++) {
    cin >> u >> v >> w;
    g[u].push_back({v, 2 * w});
    g[v].push_back({u, 2 * w});
  }
  for (long long i = 1; i <= n; i++) {
    cin >> a;
    g[n + 1].push_back({i, a});
    g[i].push_back({n + 1, a});
    d[i] = INF;
  }
  d[n + 1] = 0;
  solve();
  for (long long i = 1; i <= n; i++) {
    cout << d[i] << " ";
  }
  return 0;
}
