#include <bits/stdc++.h>
namespace shl {
inline long long read() {
  long long ret = 0, op = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') op = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    ret = ret * 10 + c - '0';
    c = getchar();
  }
  return ret * op;
}
const int N = 2e5 + 10;
struct Edge {
  int nxt, to;
  long long dis;
} e[N << 2];
int head[N], num, n, m;
inline void add(int from, int to, long long dis) {
  e[++num].nxt = head[from];
  e[num].to = to;
  e[num].dis = dis;
  head[from] = num;
}
long long dis[N], vis[N];
struct Dijkstra {
  long long id, dis;
  bool operator<(const Dijkstra &x) const { return dis > x.dis; }
};
std::priority_queue<Dijkstra> q;
int main() {
  n = read(), m = read();
  for (register int i = 1; i <= m; ++i) {
    long long x = read(), y = read(), z = read();
    add(x, y, z << 1);
    add(y, x, z << 1);
  }
  for (register int i = 1; i <= n; ++i) {
    long long x = read();
    add(i, n + 1, x);
    add(n + 1, i, x);
  }
  for (register int i = 1; i <= n; ++i) dis[i] = 1ll << 62;
  dis[n + 1] = 0;
  q.push((Dijkstra){n + 1, 0});
  while (!q.empty()) {
    int now = q.top().id;
    q.pop();
    if (vis[now]) continue;
    vis[now] = 1;
    for (register int i = head[now]; i; i = e[i].nxt)
      if (dis[e[i].to] > dis[now] + e[i].dis) {
        dis[e[i].to] = dis[now] + e[i].dis;
        q.push((Dijkstra){e[i].to, dis[e[i].to]});
      }
  }
  for (register int i = 1; i <= n; ++i) printf("%lld ", dis[i]);
  return 0;
}
}  // namespace shl
int main() {
  shl::main();
  return 0;
}
