#include <bits/stdc++.h>
using namespace std;
long long nodes, edges;
vector<pair<long long, long long>> adj[200005];
long long dist[200005];
long long arr[200005];
void Dijkstra() {
  set<pair<long long, long long>> q;
  for (int i = 1; i <= nodes; i++) {
    dist[i] = arr[i];
    q.insert({dist[i], i});
  }
  while (!q.empty()) {
    long long v = q.begin()->second;
    q.erase(q.begin());
    for (auto u : adj[v]) {
      if (dist[u.second] > dist[v] + u.first) {
        q.erase({dist[u.second], u.second});
        dist[u.second] = dist[v] + u.first;
        q.insert({dist[u.second], u.second});
      }
    }
  }
}
int main() {
  scanf("%lld%lld", &nodes, &edges);
  for (int i = 0; i < edges; i++) {
    long long a, b, w;
    scanf("%lld%lld%lld", &a, &b, &w);
    w *= 2;
    adj[a].push_back({w, b});
    adj[b].push_back({w, a});
  }
  for (int i = 1; i <= nodes; i++) {
    scanf("%lld", &arr[i]);
  }
  Dijkstra();
  for (int i = 1; i <= nodes; i++) {
    printf("%lld ", dist[i]);
  }
  return 0;
}
