#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<pair<int, long long>> G[N];
long long answer[N];
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  int n, m, u, v;
  long long w;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(make_pair(v, 2 * w));
    G[v].push_back(make_pair(u, 2 * w));
  }
  for (int i = 0; i < n; i++) {
    answer[i] = 1LL << 60;
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      Q;
  for (int i = 0; i < n; i++) {
    cin >> w;
    answer[i] = w;
    Q.push(make_pair(w, i));
  }
  while (!Q.empty()) {
    pair<long long, int> temp = Q.top();
    Q.pop();
    u = temp.second;
    if (answer[temp.second] < temp.first) {
      continue;
    }
    for (auto &t : G[u]) {
      v = t.first;
      w = t.second;
      if (w + answer[u] < answer[v]) {
        answer[v] = w + answer[u];
        Q.push(make_pair(answer[v], v));
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << answer[i] << " ";
  }
  cout << endl;
  return 0;
}
