#include <bits/stdc++.h>
using namespace std;
long long xyp(long long x, long long y) {
  if (y == 0)
    return 1;
  else if (y == 1)
    return x;
  else if (y & 1LL) {
    long long p = xyp(x, (y - 1) >> 1);
    p = (p * p) % 1000000007;
    return (x * p) % 1000000007;
  }
  long long p = xyp(x, y >> 1);
  return (p * p) % 1000000007;
}
long long n, m;
vector<vector<pair<long long, long long>>> a;
vector<long long> v;
void solve() {
  cin >> n >> m;
  a.resize(n + 1);
  for (long long i = 1; i <= m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    a[x].push_back({z, y});
    a[y].push_back({z, x});
  }
  v.resize(n + 1);
  multiset<pair<long long, long long>> ms;
  for (long long i = 1; i <= n; i++) {
    cin >> v[i];
    ms.insert({v[i], i});
  }
  while (ms.size()) {
    pair<long long, long long> tp = *ms.begin();
    ms.erase(ms.begin());
    long long curr_vertex = tp.second;
    for (auto x : a[curr_vertex]) {
      if (v[x.second] > v[curr_vertex] + 2 * x.first) {
        ms.erase(ms.find({v[x.second], x.second}));
        v[x.second] = v[curr_vertex] + 2 * x.first;
        ms.insert({v[x.second], x.second});
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << v[i] << " ";
  }
}
int main() {
  int t;
  t = 1;
  for (int z = 1; z <= t; z++) {
    solve();
  }
  return 0;
}
