#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200010;
const int Maxm = 400010;
int n, m;
int from[Maxn], nxt[Maxm * 2], to[Maxm * 2], cnt;
long long w[Maxn], dis[Maxn], vis[Maxn], len[Maxm * 2];
struct Node {
  int u;
  long long dis;
  inline bool operator<(const Node &a) const { return dis > a.dis; }
};
inline void add_edge(int a, int b, long long l) {
  len[cnt] = l;
  to[cnt] = b;
  nxt[cnt] = from[a];
  from[a] = cnt++;
}
void Dijkstra(int Begin) {
  int u = Begin;
  priority_queue<Node> q;
  q.push((Node){u, 0});
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) dis[i] = (long long)1e13;
  dis[u] = 0;
  while (!q.empty()) {
    u = q.top().u;
    q.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (int i = from[u]; i != -1; i = nxt[i]) {
      int v = to[i];
      if (dis[v] > dis[u] + len[i]) {
        dis[v] = dis[u] + len[i];
        q.push((Node){v, dis[v]});
      }
    }
  }
}
int main() {
  memset(from, -1, sizeof(from));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long l;
    scanf("%d%d%lld", &u, &v, &l);
    add_edge(u, v, l * 2);
    add_edge(v, u, l * 2);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &w[i]);
    add_edge(0, i, w[i]);
  }
  Dijkstra(0);
  for (int i = 1; i <= n; i++) {
    printf("%lld ", dis[i]);
  }
  puts("");
  return 0;
}
