#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 100;
vector<pair<long long, long long> > g[N];
long long a[N];
long long d[N];
set<pair<long long, long long> > pq;
void dijkstra() {
  while (!pq.empty()) {
    auto u = pq.begin();
    auto v = *u;
    pq.erase(u);
    for (auto x : g[v.second]) {
      long long to = x.first;
      long long wt = x.second;
      long long dist = 2 * wt + d[v.second];
      if (d[to] > dist) {
        if (pq.count({d[to], to})) pq.erase({d[to], to});
        d[to] = dist;
        pq.insert({dist, to});
      }
    }
  }
  return;
}
int main(int argc, char const *argv[]) {
  long long n, m;
  cin >> n >> m;
  long long u, v, w;
  for (long long i = 1; i <= m; i++) {
    cin >> u >> v >> w;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    d[i] = a[i];
    pq.insert({a[i], i});
  }
  dijkstra();
  for (long long i = 1; i <= n; i++) {
    cout << d[i] << ' ';
  }
  cout << '\n';
}
