#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
vector<vector<pll>> edges;
void solve() {
  ll n, m;
  cin >> n >> m;
  edges.resize(n);
  for (int i = 0, _n = (m); i < _n; i++) {
    ll u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    edges[u].push_back({v, w});
    edges[v].push_back({u, w});
  }
  vector<long long> a(n);
  for (int i = 0, _n = (n); i < _n; i++) cin >> a[i];
  set<pll> second;
  for (int i = 0, _n = (n); i < _n; i++) {
    second.insert({a[i], i});
  }
  vector<bool> vis(n, 0);
  while (!second.empty()) {
    auto root = *(second.begin());
    second.erase(second.begin());
    for (auto& child : edges[root.second]) {
      if (vis[child.first]) continue;
      ll to = child.first;
      ll wt = child.second;
      if (2 * wt + root.first < a[to]) {
        second.erase({a[to], to});
        a[to] = 2 * wt + root.first;
        second.insert({a[to], to});
      }
    }
    vis[root.second] = 1;
  }
  for (auto& elem : a) {
    cout << elem << ' ';
  }
  cout << '\n';
  return;
}
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
