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