#include <bits/stdc++.h>
using namespace std;
const int MX = 200001;
int n, m;
long long dist[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>>>
    p;
void dijkstra() {
  while (!p.empty()) {
    pair<long long, long long> x = p.top();
    p.pop();
    if (x.first != dist[x.second]) continue;
    for (auto y : adj[x.second]) {
      if (dist[y.first] > x.first + 2 * y.second) {
        dist[y.first] = x.first + 2 * y.second;
        p.push(pair<long long, long long>(dist[y.first], y.first));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long v, u, w;
    cin >> v >> u >> w;
    adj[u].push_back(pair<long long, long long>(v, w));
    adj[v].push_back(pair<long long, long long>(u, w));
  }
  for (int i = 1; i <= n; i++) {
    cin >> dist[i];
    p.push(pair<long long, long long>(dist[i], i));
  }
  dijkstra();
  for (int i = 1; i <= n; i++) cout << dist[i] << " ";
  cout << endl;
}
