#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <typename... Vectors>
void resizeVectors(int newSize, Vectors&... vectors) {
  (vectors.resize(newSize), ...);
}
void resizeVectors(int unusedNewSize) {}
template <typename... Vectors>
void readEntryHelper(int i, Vectors&... vectors) {
  ((cin >> vectors[i]), ...);
}
template <typename... Vectors>
void readVectors(int count, Vectors&... vectors) {
  (resizeVectors(count, (vectors, ...)));
  for (int i = 0; i < count; ++i) {
    (readEntryHelper(i, (vectors, ...)));
  }
}
using ll = signed long long;
using ld = long double;
void $main();
int main() {
  int numTests = 1;
  if (0) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> numTests;
  } else {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
  }
  for (int i = 0; i < numTests; ++i) {
    $main();
    if (0) {
      cout << "-----\n";
    }
  }
}
using P = pair<ll, int>;
void $main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, ll>>> g(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    --u;
    --v;
    g[u].emplace_back(v, w);
    g[v].emplace_back(u, w);
  }
  vector<ll> a;
  readVectors(n, a);
  vector<ll> ans(a);
  priority_queue<P, vector<P>, greater<P>> q;
  for (int i = 0; i < n; ++i) {
    q.emplace(ans[i], i);
  }
  while (q.size()) {
    auto ev = q.top();
    q.pop();
    auto [ansv, v] = ev;
    if (ansv > ans[v]) continue;
    for (auto edge : g[v]) {
      ll nans = ans[v] + 2 * edge.second;
      ll& cans = ans[edge.first];
      if (cans > nans) {
        cans = nans;
        q.emplace(cans, edge.first);
      }
    }
  }
  for (ll x : ans) cout << x << " ";
  cout << "\n";
}
