#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 2e5 + 5;
struct edge {
  long long vertex, cost;
  edge(long long tt, long long cc) {
    vertex = tt;
    cost = cc;
  }
};
vector<edge> g[N];
long long n, m, a[N], d[N];
set<pair<long long, long long>> q;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long v, u, w;
    cin >> v >> u >> w;
    g[v - 1].push_back(edge(u - 1, w));
    g[u - 1].push_back(edge(v - 1, w));
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    d[i] = a[i];
    q.insert(make_pair(d[i], i));
  }
  while (!q.empty()) {
    int v = q.begin()->second;
    q.erase(q.begin());
    for (edge to : g[v]) {
      if (d[to.vertex] > d[v] + to.cost * 2) {
        q.erase(make_pair(d[to.vertex], to.vertex));
        d[to.vertex] = d[v] + to.cost * 2;
        q.insert(make_pair(d[to.vertex], to.vertex));
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << d[i] << " ";
  }
  return 0;
}
