#include <bits/stdc++.h>
using namespace std;
int n, m;
const int INF = 570000000;
struct Edge {
  int vertex;
  long long weight;
  Edge(int v, long long w) {
    vertex = v;
    weight = w;
  }
};
vector<vector<Edge>> gr;
vector<long long> cost;
vector<long long> distances;
void make_Dijkstra() {
  set<pair<long long, int>> heap;
  for (int i = 0; i < n; ++i) {
    heap.insert(make_pair(distances[i], i));
  }
  while (!heap.empty()) {
    int v = heap.begin()->second;
    heap.erase(heap.begin());
    for (Edge e : gr[v]) {
      int nv = e.vertex;
      long long weight = e.weight;
      if (distances[nv] > distances[v] + weight) {
        heap.erase(make_pair(distances[nv], nv));
        distances[nv] = distances[v] + weight;
        heap.insert(make_pair(distances[nv], nv));
      }
    }
  }
}
int main() {
  cin >> n >> m;
  gr.assign(n, vector<Edge>());
  distances.resize(n);
  cost.resize(n);
  while (m) {
    int a_from, b_to;
    long long w;
    cin >> a_from >> b_to >> w;
    Edge e1(b_to - 1, w * 2);
    Edge e2(a_from - 1, w * 2);
    gr[a_from - 1].push_back(e1);
    gr[b_to - 1].push_back(e2);
    --m;
  }
  for (int i = 0; i < n; ++i) {
    long long cost_of_consert;
    cin >> cost_of_consert;
    cost[i] = cost_of_consert;
    distances[i] = cost_of_consert;
  }
  make_Dijkstra();
  for (int i = 0; i < n; ++i) {
    cout << distances[i] << ' ';
  }
  return 0;
}
