#include <bits/stdc++.h>
using namespace std;
struct Graph {
  struct Edge {
    int to;
    long long cost;
    Edge(int to, long long cost) : to(to), cost(cost) {}
  };
  vector<vector<Edge>> es;
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  Graph g;
  g.es.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    long long w;
    cin >> a >> b >> w;
    g.es[a - 1].emplace_back(b - 1, w);
    g.es[b - 1].emplace_back(a - 1, w);
  }
  auto dist = vector<long long>(n);
  for (int v = 0; v < n; ++v) cin >> dist[v];
  auto comp = [&](int v1, int v2) {
    return tie(dist[v1], v1) < tie(dist[v2], v2);
  };
  auto q = set<int, decltype(comp)>(comp);
  for (int v = 0; v < n; ++v) q.insert(v);
  while (not q.empty()) {
    auto v = *q.begin();
    q.erase(q.begin());
    for (auto&& e : g.es[v]) {
      if (dist[v] + 2 * e.cost < dist[e.to]) {
        q.erase(q.find(e.to));
        dist[e.to] = dist[v] + 2 * e.cost;
        q.insert(e.to);
      }
    }
  }
  for (int v = 0; v < n; ++v) cout << dist[v] << ' ';
  cout << '\n';
}
