#include <bits/stdc++.h>
using namespace std;
vector<bool> visited;
vector<long long int> dis;
vector<long long int> cost;
void dijkstras(long long int u, vector<pair<long long int, long long int>>* adj,
               long long int n) {
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int>>,
                 greater<pair<long long int, long long int>>>
      heap;
  for (long long int i = 0; i < n; i++) {
    heap.push({dis[i], i});
  }
  while (!heap.empty()) {
    pair<long long int, long long int> x = heap.top();
    heap.pop();
    if (visited[x.second]) continue;
    visited[x.second] = true;
    for (long long int i = 0; i < adj[x.second].size(); i++) {
      if (dis[adj[x.second][i].first] > x.first + 2 * adj[x.second][i].second) {
        dis[adj[x.second][i].first] = x.first + 2 * adj[x.second][i].second;
        if (dis[adj[x.second][i].first] != 1e18)
          heap.push({dis[adj[x.second][i].first], adj[x.second][i].first});
      }
    }
  }
}
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<pair<long long int, long long int>> adj[n];
  for (long long int i = 0; i < m; i++) {
    long long int x, y, z;
    cin >> x >> y >> z;
    adj[x - 1].push_back({y - 1, z});
    adj[y - 1].push_back({x - 1, z});
  }
  dis.resize(n);
  cost.resize(n);
  visited.assign(n, false);
  long long int source = -1;
  long long int maxcost = 1e18;
  for (long long int i = 0; i < n; i++) {
    cin >> cost[i];
    dis[i] = cost[i];
    if (dis[i] < maxcost) {
      source = i;
      maxcost = dis[i];
    }
  }
  dijkstras(source, adj, n);
  for (long long int i = 0; i < n; i++) {
    cout << dis[i] << " ";
  }
  cout << endl;
}
