#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 = ll;
struct Node {
  P value;
  int il, ir;
  int ansi;
  Node* nl = nullptr;
  Node* nr = nullptr;
  void push() {
    if (ir - il > 1) {
      value = min(nl->value, nr->value);
      if (nl->value < nr->value) {
        ansi = nl->ansi;
        value = nl->value;
      } else {
        ansi = nr->ansi;
        value = nr->value;
      }
    }
  }
};
Node* build(int l, int r) {
  Node* n = new Node;
  n->il = l;
  n->ir = r;
  n->ansi = l;
  if (r - l > 1) {
    int m = (l + r) / 2;
    n->nl = build(l, m);
    n->nr = build(m, r);
    n->push();
  }
  return n;
}
pair<P, int> extract(Node* node, int ql, int qr) {
  if (ql >= node->ir || node->il >= qr) return {1e18, -1};
  if (ql <= node->il && node->ir <= qr) {
    auto ret = make_pair(node->value, node->ansi);
    return ret;
  }
  auto ret = min(extract(node->nl, ql, qr), extract(node->nr, ql, qr));
  node->push();
  return ret;
}
void update(Node* node, int i, P x) {
  if (i >= node->ir || node->il >= i + 1) return;
  if (i <= node->il && node->ir <= i + 1) {
    node->value = x;
    return;
  }
  update(node->nl, i, x);
  update(node->nr, i, x);
  node->push();
}
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);
  Node* tree = build(0, n);
  for (int i = 0; i < n; ++i) {
    update(tree, i, ans[i]);
  }
  int nextFree = n;
  while (nextFree > 0) {
    auto t = extract(tree, 0, n);
    auto [ev, v] = t;
    auto ansv = ev;
    assert(ansv == ans[v]);
    --nextFree;
    update(tree, v, 1e18);
    for (auto edge : g[v]) {
      ll nans = ans[v] + 2 * edge.second;
      ll& cans = ans[edge.first];
      if (cans > nans) {
        cans = nans;
        update(tree, edge.first, cans);
      }
    }
  }
  for (ll x : ans) cout << x << " ";
  cout << "\n";
}
