#include <bits/stdc++.h>
using namespace std;
long long N, M, u, v, w, d[int(2e5) + 5];
bool vis[int(2e5) + 5];
struct Node {
  long long v, w;
  friend bool operator<(const Node n1, const Node n2) { return n1.w > n2.w; }
  Node(long long v = 0, long long w = 0) : v(v), w(w){};
} cur;
vector<Node> adj[int(2e5) + 5];
priority_queue<Node> q;
int main() {
  scanf("%lld%lld", &N, &M);
  for (long long i = 1; i <= M; i++) {
    scanf("%lld%lld%lld", &u, &v, &w);
    adj[u].push_back(Node(v, w << 1));
    adj[v].push_back(Node(u, w << 1));
  }
  for (long long i = 1; i <= N; i++) {
    scanf("%lld", &d[i]);
    q.push(Node(i, d[i]));
  }
  while (!q.empty()) {
    cur = q.top();
    q.pop();
    u = cur.v;
    if (vis[u]) continue;
    vis[u] = 1;
    for (long long i = 0; i < adj[u].size(); i++) {
      v = adj[u][i].v;
      w = adj[u][i].w;
      if (!vis[v] && d[u] + w < d[v]) {
        d[v] = d[u] + w;
        q.push(Node(v, d[v]));
      }
    }
  }
  for (long long i = 1; i <= N; i++) printf("%lld ", d[i]);
  return 0;
}
