#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200000 + 10;
struct Edge {
  long long from, to;
  long long dist;
  Edge(long long f = 0, long long t = 0, long long d = 0)
      : from(f), to(t), dist(d) {}
};
struct HeapNode {
  long long d;
  long long u;
  bool operator<(const HeapNode& rhs) const { return d > rhs.d; }
};
Edge E[2 * maxn];
vector<long long> G[maxn];
long long n, m, done[maxn], vis[maxn];
long long d[maxn];
pair<long long, long long> arr[maxn];
priority_queue<HeapNode> Q;
void Dijkstra() {
  while (!Q.empty()) {
    HeapNode x = Q.top();
    Q.pop();
    long long u = x.u, val = x.d;
    if (val != d[u]) continue;
    for (long long i = 0; i < G[u].size(); i++) {
      Edge e = E[G[u][i]];
      if (d[e.to] > d[u] + 2 * e.dist)
        d[e.to] = d[u] + 2 * e.dist, Q.push((HeapNode){d[e.to], e.to});
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (long long i = 0; i < m; i++) {
    long long x, y, z;
    scanf("%I64d%I64d%I64d", &x, &y, &z);
    E[2 * i] = Edge(x, y, z);
    E[2 * i + 1] = Edge(y, x, z);
    G[x].push_back(2 * i);
    G[y].push_back(2 * i + 1);
  }
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d", &d[i]);
    Q.push((HeapNode){d[i], i});
  }
  Dijkstra();
  for (long long i = 1; i <= n; i++) printf("%I64d ", d[i]);
  return 0;
}
