#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-ffloat-store")
#pragma GCC optimize("-fno-defer-pop")
long long power(long long a, long long b, long long m) {
  if (b == 0) return 1;
  if (b == 1) return a % m;
  long long t = power(a, b / 2, m);
  t = (t * t) % m;
  if (b & 1) t = (t * a) % m;
  return t;
}
using namespace std;
vector<long long> g[200001];
int main() {
  ;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  map<pair<long long, long long>, long long> mt;
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    g[u].push_back(v);
    g[v].push_back(u);
    mt[make_pair(u, v)] = w;
    mt[make_pair(v, u)] = w;
  }
  long long key[n + 1];
  set<pair<long long, long long> > st;
  for (long long i = 1; i <= n; i++) {
    cin >> key[i];
    st.insert(make_pair(key[i], i));
  }
  while (!st.empty()) {
    pair<long long, long long> x = *st.begin();
    st.erase(st.begin());
    long long a = x.first;
    long long b = x.second;
    for (long long i = 0; i < g[b].size(); i++) {
      if (key[g[b][i]] > 2 * mt[make_pair(b, g[b][i])] + key[b]) {
        st.erase(st.find(make_pair(key[g[b][i]], g[b][i])));
        key[g[b][i]] = 2 * mt[make_pair(b, g[b][i])] + key[b];
        st.insert(make_pair(key[g[b][i]], g[b][i]));
      }
    }
  }
  for (long long i = 1; i <= n; i++) cout << key[i] << " ";
}
