#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, l, sum = 0, flag = 0, ans[200005], m, tot = 0, t,
                         a[200005] = {0}, w;
vector<pair<long long, long long> > v[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> j >> k >> w;
    v[j].push_back({k, w});
    v[k].push_back({j, w});
  }
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int> >,
                 greater<pair<long long int, long long int> > >
      pq;
  for (i = 1; i <= n; i++) {
    cin >> k;
    pq.push({k, i});
  }
  while (!pq.empty()) {
    auto cur = pq.top();
    pq.pop();
    if (a[cur.second] != 0) continue;
    ans[int(cur.second)] = cur.first;
    a[cur.second] = 1;
    for (auto i : v[cur.second]) {
      if (!a[i.first]) {
        pq.push({cur.first + 2 * i.second, i.first});
      }
    }
  }
  for (i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
