#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
inline void in(long long &x) {
  int f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s <= '9' && s >= '0') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  x *= f;
}
long long n, m;
struct Edge {
  long long v, w;
};
vector<Edge> g[maxn];
long long vis[maxn], d[maxn];
void spfa(long long s) {
  memset(d, 0x3f, sizeof(d));
  deque<long long> q;
  d[s] = 0;
  q.push_back(s);
  vis[s] = 1;
  while (!q.empty()) {
    long long u = q.front();
    q.pop_front();
    vis[u] = 0;
    int k = g[u].size();
    for (register int i = 0; i < k; i++) {
      Edge e = g[u][i];
      long long w = e.w, v = e.v;
      if (d[u] + w < d[v]) {
        d[v] = d[u] + w;
        if (vis[v] == 0) {
          if (!q.empty() && d[v] < d[q.front()])
            q.push_front(v);
          else
            q.push_back(v);
          vis[v] = 1;
        }
      }
    }
  }
}
int main() {
  in(n), in(m);
  for (register long long i = 1; i <= m; ++i) {
    long long u, v, k;
    in(u), in(v), in(k);
    g[u].push_back((Edge){v, k * 2});
    g[v].push_back((Edge){u, k * 2});
  }
  for (register long long i = 1; i <= n; ++i) {
    long long a;
    in(a);
    g[0].push_back((Edge){i, a});
  }
  spfa(0);
  for (long long i = 1; i <= n; i++) {
    printf("%I64d ", d[i]);
  }
  return 0;
}
