#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int v;
  long long w;
  Edge(int v = 0, long long w = 0) : v(v), w(w) {}
};
struct Node {
  int id;
  long long d;
  Node(int id = 0, long long d = 0) : id(id), d(d) {}
  bool operator<(const Node& n1) const { return d > n1.d; }
};
vector<Edge> adj[200005];
int n, m;
long long d[200005];
bool vis[200005];
void dijkstra() {
  memset(vis, 0, sizeof(vis));
  memset(d, 127, sizeof(d));
  d[0] = 0;
  priority_queue<Node> q;
  q.push(Node(0, 0));
  int u, v;
  long long w;
  while (!q.empty()) {
    u = q.top().id;
    q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = 0; i < (int)adj[u].size(); i++) {
      v = adj[u][i].v;
      w = adj[u][i].w;
      if (d[u] + w < d[v]) {
        d[v] = d[u] + w;
        q.push(Node(v, d[v]));
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  long long w;
  for (int u, v, i = 1; i <= m; i++) {
    scanf("%d%d%lld", &u, &v, &w);
    adj[u].push_back(Edge(v, 2 * w));
    adj[v].push_back(Edge(u, 2 * w));
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &w);
    adj[0].push_back(Edge(i, w));
  }
  dijkstra();
  for (int i = 1; i <= n; i++) printf("%lld ", d[i]);
  return 0;
}
