#include <bits/stdc++.h>
using namespace std;
const int MX = 200001;
int n, m;
long long a[MX];
vector<pair<long long, long long>> adj[MX];
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
               greater<pair<long long, long long>>>
    todo;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long v, u, w;
    cin >> v >> u >> w;
    adj[v].push_back({u, w}), adj[u].push_back({v, w});
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    todo.push({a[i], i});
  }
  while (todo.size()) {
    auto x = todo.top();
    todo.pop();
    if (x.first != a[x.second]) continue;
    for (auto y : adj[x.second])
      if (x.first + 2 * y.second < a[y.first]) {
        todo.push({a[y.first] = x.first + 2 * y.second, y.first});
      }
  }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
}
