#include <bits/stdc++.h>
using namespace std;
long long n, m, u;
const long long maxn = 3e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
long long d[maxn], a[maxn];
vector<pair<long long, long long> > adj[maxn];
void dijkstra() {
  set<pair<long long, long long> > st;
  for (long long i = 0; i <= n; i++) {
    st.insert(make_pair(d[i], i));
  }
  while (!st.empty()) {
    long long v = st.begin()->second;
    st.erase(st.begin());
    for (auto i : adj[v]) {
      long long u = i.first;
      long long w = i.second;
      if (d[u] > (2 * w) + d[v]) {
        st.erase(make_pair(d[u], u));
        d[u] = (2 * w) + d[v];
        st.insert(make_pair(d[u], u));
      }
    }
  }
}
int32_t main() {
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long a, b, w;
    cin >> a >> b >> w;
    adj[a].push_back(make_pair(b, w));
    adj[b].push_back(make_pair(a, w));
  }
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    d[i] = a[i];
  }
  dijkstra();
  for (long long i = 1; i <= n; i++) {
    cout << d[i] << " ";
  }
}
