#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<long long, long long>> q;
long long ans[200010];
bool col[200010];
vector<pair<long long, long long>> adj[200010];
int main() {
  long long n, m, a, b, c;
  scanf("%lld %lld", &n, &m);
  while (m--) {
    scanf("%lld %lld %lld", &a, &b, &c);
    adj[a].push_back({b, -c});
    adj[b].push_back({a, -c});
  }
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &c);
    q.push({-c, i});
  }
  pair<long long, long long> u, v;
  while (!q.empty()) {
    u = q.top();
    q.pop();
    if (ans[u.second]) continue;
    ans[u.second] = -u.first;
    col[u.second] = true;
    for (auto nowNode : adj[u.second]) {
      v.second = nowNode.first;
      v.first = u.first + 2ll * nowNode.second;
      q.push(v);
    }
  }
  for (long long i = 1; i <= n; i++) printf("%lld ", ans[i]);
  return 0;
}
