#include <bits/stdc++.h>
using namespace std;
const int maxn = 200009;
const int MOD = 1e9 + 7;
vector<pair<int, int64_t>> V[maxn];
int vis[maxn];
int64_t cst[maxn];
int main() {
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int64_t u, v, w;
    cin >> u >> v >> w;
    V[u].emplace_back(v, w);
    V[v].emplace_back(u, w);
  }
  priority_queue<pair<int64_t, int>> que;
  for (int i = 1; i <= n; ++i) {
    cin >> cst[i];
    que.emplace(-cst[i], i);
  }
  while (((int)(que).size())) {
    auto p = que.top();
    que.pop();
    if (vis[p.second]) continue;
    vis[p.second] = 1;
    for (auto edge : V[p.second]) {
      if (cst[edge.first] > cst[p.second] + 2 * edge.second) {
        cst[edge.first] = cst[p.second] + 2 * edge.second;
        que.emplace(-cst[edge.first], edge.first);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << cst[i] << " ";
  }
  cout << '\n';
  return 0;
}
