#include <bits/stdc++.h>
using namespace std;
int n1, m1, s;
long long INF = 1000000000005LL;
long long d[200005];
long long p[200005];
long long ticket[200005];
struct Edge {
  int from, to;
  long long dist;
  Edge(int u, int v, long long d) : from(u), to(v), dist(d) {}
};
struct HeapNode {
  long long d;
  int u;
  bool operator<(const HeapNode& rhs) const { return d > rhs.d; }
};
struct Dijkstra {
  int m;
  vector<Edge> edges;
  vector<int> G[200005];
  bool done[200005];
  void init(int n) {
    for (int i = 0; i < n; i++) G[i].clear();
    edges.clear();
  }
  void AddEdge(int from, int to, long long dist) {
    edges.push_back(Edge(from, to, dist));
    m = edges.size();
    G[from].push_back(m - 1);
  }
  void dijkstra(int s) {
    priority_queue<HeapNode> Q;
    for (int i = 0; i <= n1; i++) d[i] = INF;
    d[s] = 0;
    memset(done, 0, sizeof(done));
    Q.push((HeapNode){0, s});
    while (!Q.empty()) {
      HeapNode x = Q.top();
      Q.pop();
      int u = x.u;
      if (done[u]) {
        continue;
      }
      done[u] = true;
      for (int i = 0; i < G[u].size(); i++) {
        Edge& e = edges[G[u][i]];
        if (d[e.to] > d[u] + e.dist) {
          d[e.to] = d[u] + e.dist;
          p[e.to] = G[u][i];
          Q.push((HeapNode){d[e.to], e.to});
        }
      }
    }
  }
} aa;
int main() {
  cin >> n1 >> m1;
  aa.init(n1);
  for (int i = 0; i < m1; i++) {
    int a, b;
    long long c;
    cin >> a >> b >> c;
    c *= 2;
    aa.AddEdge(a, b, c);
    aa.AddEdge(b, a, c);
  }
  for (int i = 1; i <= n1; i++) {
    long long a;
    cin >> a;
    ticket[i] = a;
    aa.AddEdge(0, i, a);
  }
  aa.dijkstra(0);
  for (int i = 1; i <= n1; i++) {
    cout << d[i] << " ";
  }
  return 0;
}
