#include <bits/stdc++.h>
const long long INF = 0x3f3f3f3f3f3f3f3f, MAXN = 2e5 + 10;
long long a[MAXN];
struct edge {
  long long v, w;
};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  std::vector<std::vector<edge> > G(n + 1, std::vector<edge>());
  for (int i = 1; i <= m; ++i) {
    long long u, v, w;
    scanf("%lld%lld%lld", &u, &v, &w);
    w *= 2;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    G[0].push_back({i, a[i]});
    G[i].push_back({0, a[i]});
  }
  std::priority_queue<std::pair<long long, long long>,
                      std::vector<std::pair<long long, long long> >,
                      std::greater<std::pair<long long, long long> > >
      que;
  std::vector<long long> dis(n + 1, INF);
  que.push({0, 0});
  dis[0] = 0;
  while (!que.empty()) {
    std::pair<long long, long long> p = que.top();
    que.pop();
    int d = p.first, u = p.second;
    if (dis[u] < d) continue;
    for (auto &i : G[u])
      if (dis[i.v] > dis[u] + i.w)
        dis[i.v] = dis[u] + i.w, que.push({dis[i.v], i.v});
  }
  for (int i = 1; i <= n; ++i) printf("%lld ", dis[i]);
  return 0;
}
