#include <bits/stdc++.h>
using namespace std;
long long ans[200005];
vector<vector<pair<long long, long long> > > G(200005);
int main() {
  long long i, j, n, m, a, b, c;
  priority_queue<pair<long long, long long> > pq;
  scanf("%lld %lld", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%lld %lld %lld", &a, &b, &c);
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }
  for (i = 1; i <= n; i++) {
    scanf("%lld", &ans[i]);
    pq.push({-ans[i], i});
  }
  while (!pq.empty()) {
    pair<long long, long long> tp = pq.top();
    pq.pop();
    tp.first *= -1;
    if (tp.first > ans[tp.second]) continue;
    ans[tp.second] = tp.first;
    for (pair<long long, long long> next : G[tp.second]) {
      long long poss = next.second * 2 + tp.first;
      if (poss < ans[next.first]) {
        pq.push({-poss, next.first});
      }
    }
  }
  for (i = 1; i <= n; i++) printf("%lld ", ans[i]);
  printf("\n");
  return 0;
}
