#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, long long int>>> v(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    long long int c;
    cin >> a >> b >> c;
    v[--a].push_back(make_pair(--b, c));
    v[b].push_back(make_pair(a, c));
  }
  vector<long long int> a(n);
  set<pair<long long int, int>> s;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s.insert(make_pair(a[i], i));
  }
  while (!s.empty()) {
    int u = s.begin()->second;
    long long int cost = s.begin()->first;
    s.erase(s.begin());
    for (auto p : v[u]) {
      if (cost + 2 * p.second < a[p.first]) {
        s.erase(s.find(make_pair(a[p.first], p.first)));
        a[p.first] = cost + 2 * p.second;
        s.insert(make_pair(a[p.first], p.first));
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
  return 0;
}
