#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > neig[n + 1];
  long long a[n + 1];
  while (m--) {
    long long u, v, w;
    cin >> u >> v >> w;
    neig[u].push_back({v, w});
    neig[v].push_back({u, w});
  }
  set<pair<long long, long long> > s;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s.insert({a[i], i});
  }
  while (s.begin() != s.end()) {
    int u = (*s.begin()).second;
    s.erase(s.begin());
    for (pair<long long, long long> p : neig[u]) {
      int v = p.first;
      if (a[v] > 2 * p.second + a[u]) {
        s.erase({a[v], v});
        a[v] = 2 * p.second + a[u];
        s.insert({a[v], v});
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
