#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> adj[200005];
vector<pair<long long, long long>> cost;
vector<bool> vis(200005, false);
vector<long long> dist(200005, LONG_MAX);
void dij(long long n) {
  set<pair<long long, long long>> st;
  for (long long i = 0; i < n; i++) st.insert(make_pair(dist[i], i));
  while (!st.empty()) {
    auto f = st.begin();
    long long l = f->first, r = f->second;
    st.erase(f);
    vis[r] = true;
    for (auto e : adj[r]) {
      if (vis[e.first] == false && dist[e.first] > l + 2 * e.second) {
        st.erase(st.find(make_pair(dist[e.first], e.first)));
        dist[e.first] = l + 2 * e.second;
        st.insert(make_pair(dist[e.first], e.first));
      }
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, a, b, w;
  cin >> n >> m;
  cost.resize(n);
  for (long long i = 0; i < m; i++) {
    cin >> a >> b >> w;
    a--, b--;
    adj[a].push_back(make_pair(b, w));
    adj[b].push_back(make_pair(a, w));
  }
  long long mn = 1e18, mni = -1;
  for (long long i = 0; i < n; i++) {
    cin >> dist[i];
    if (mn > dist[i]) mn = dist[i], mni = i;
  }
  dij(n);
  for (long long i = 0; i < n; i++) cout << dist[i] << " ";
  cout << "\n";
  return 0;
}
