#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005, maxm = maxn * 3;
int n, m, i, s, x, y, head[maxn];
long long z, d[maxn];
struct node {
  int to, nxt;
  long long w;
} e[maxm];
struct mdata {
  int x;
  long long y;
  bool operator<(const mdata& a) const { return y > a.y; }
} p, k;
priority_queue<mdata> q;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x;
}
inline void add(int x, int y, long long z) {
  e[++s].to = y;
  e[s].nxt = head[x];
  e[s].w = z;
  head[x] = s;
}
void Dijkstra() {
  memset(d, 0x6f, sizeof(d));
  d[0] = 0;
  p.x = p.y = 0;
  q.push(p);
  while (q.empty() == 0) {
    p = q.top();
    q.pop();
    if (p.y != d[p.x]) continue;
    for (int i = head[p.x]; i; i = e[i].nxt)
      if (d[p.x] + e[i].w < d[e[i].to]) {
        d[e[i].to] = d[p.x] + e[i].w;
        k.x = e[i].to;
        k.y = d[k.x];
        q.push(k);
      }
  }
}
int main() {
  n = read();
  m = read();
  s = 0;
  for (i = 1; i <= m; i++) {
    x = read();
    y = read();
    z = read();
    z *= 2;
    add(x, y, z);
    add(y, x, z);
  }
  for (i = 1; i <= n; i++) {
    z = read();
    add(0, i, z);
  }
  Dijkstra();
  for (i = 1; i <= n; i++) printf("%lld ", d[i]);
  return 0;
}
