#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
vector<pair<long long, long long> > g[N];
bool vis[N];
long long dist[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    w *= 2;
    g[u].push_back({w, v});
    g[v].push_back({w, u});
  }
  set<pair<long long, long long> > s;
  for (long long i = 1; i <= n; i++) {
    cin >> dist[i];
    s.insert({dist[i], i});
  }
  while (!s.empty()) {
    cout << "\n\n\n";
    pair<long long, long long> front = *s.begin();
    s.erase(front);
    long long cur_weight = front.first;
    long long cur_node = front.second;
    if (vis[cur_node]) {
      continue;
    }
    vis[cur_node] = true;
    for (pair<long long, long long> p : g[cur_node]) {
      long long edge_weight = p.first;
      long long next_node = p.second;
      if (edge_weight + dist[cur_node] < dist[next_node]) {
        dist[next_node] = edge_weight + dist[cur_node];
        s.insert({dist[next_node], next_node});
      }
    }
  }
  for (long long i = 1; i <= n; i++) cout << dist[i] << " ";
  cout << "\n";
}
