#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
vector<pair<int, long long>> g[N];
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> d(n + 1, LLONG_MAX);
  d[0] = 0;
  for (int i = 0; i < m; ++i) {
    int v, u;
    long long w;
    cin >> v >> u >> w;
    w *= 2;
    g[v].push_back({u, w});
    g[u].push_back({v, w});
  }
  for (int i = 1; i <= n; ++i) {
    long long w;
    cin >> w;
    g[0].push_back({i, w});
    g[i].push_back({0, w});
  }
  set<pair<long long, int>> q;
  q.insert({0, 0});
  while (!q.empty()) {
    int v = q.begin()->second;
    q.erase(q.begin());
    for (int i = 0; i < g[v].size(); ++i) {
      int to = g[v][i].first;
      long long w = g[v][i].second;
      if (d[v] + w < d[to]) {
        q.erase({d[to], to});
        d[to] = d[v] + w;
        q.insert({d[to], to});
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << d[i] << ' ';
  }
  return 0;
}
