#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long d[n + 1], pr[n + 1];
  vector<pair<long long, long long>> g[n + 1];
  set<pair<long long, long long>> q;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    g[x].push_back({2 * w, y});
    g[y].push_back({2 * w, x});
  }
  for (long long i = 1; i <= n; i++) {
    cin >> pr[i];
    d[i] = pr[i];
    q.emplace(d[i], i);
  }
  while (!q.empty()) {
    long long v = q.begin()->second, xx = q.begin()->first;
    q.erase(q.begin());
    if (xx > d[v]) continue;
    for (long long j = 0; j < g[v].size(); ++j) {
      long long to = g[v][j].second, len = g[v][j].first;
      if (d[v] + len < d[to]) {
        q.erase(make_pair(d[to], to));
        d[to] = d[v] + len;
        q.insert(make_pair(d[to], to));
      }
    }
  }
  for (long long i = 1; i <= n; i++) cout << d[i] << " ";
  cout << endl;
}
