#include <bits/stdc++.h>
using namespace std;
int b[200005], vis[200005], x, y, z, xnext, cnt, m, n, s, en, cont, flag = 1;
long long d[200005];
struct node {
  int next, to;
  long long w;
} e[700005];
void fpush(int u, int v, long long w) {
  e[++cnt].next = b[u];
  e[cnt].w = w;
  e[cnt].to = v;
  b[u] = cnt;
}
struct nn {
  int to;
  long long val;
  bool operator<(const nn s2) const { return val > s2.val; }
};
priority_queue<nn> a;
void SPFA() {
  a.push((nn){s, 0});
  d[s] = 0;
  while (!a.empty()) {
    cont++;
    nn now;
    now = a.top();
    a.pop();
    vis[now.to] = 0;
    for (int i = b[now.to]; i; i = e[i].next) {
      xnext = e[i].to;
      if (d[now.to] + e[i].w < d[xnext]) {
        d[xnext] = d[now.to] + e[i].w;
        if (!vis[xnext]) {
          a.push((nn){xnext, d[xnext]});
          vis[xnext] = true;
        }
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  memset(d, 0x3f3f3f3f, sizeof(d));
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    fpush(u, v, w * 2);
    fpush(v, u, w * 2);
  }
  for (int i = 1; i <= n; i++) {
    long long w;
    scanf("%lld", &w);
    fpush(0, i, w);
  }
  s = 0;
  SPFA();
  printf("%lld", d[1]);
  for (int i = 2; i <= n; i++) printf(" %lld", d[i]);
}
