#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 10;
struct E {
  long long v, w;
};
struct Q {
  long long u, sum;
  bool operator<(Q b) const { return sum > b.sum; }
};
vector<E> G[mx];
long long val[mx];
long long dis[mx];
long long n, m;
int inq[mx];
void spfa() {
  priority_queue<Q> q;
  for (int i = 1; i <= n; ++i) dis[i] = val[i], q.push({i, val[i]}), inq[i] = 0;
  while (!q.empty()) {
    Q p = q.top();
    q.pop();
    if (!inq[p.u]) {
      inq[p.u] = 1;
      for (auto V : G[p.u]) {
        long long v = V.v, w = V.w;
        if (p.sum + w < dis[v]) {
          dis[v] = p.sum + w;
          q.push({v, p.sum + w});
        }
      }
    }
  }
}
int main() {
  int ok = 0;
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= m; ++i) {
    long long u, v, w;
    scanf("%lld%lld%lld", &u, &v, &w);
    G[u].push_back({v, 2 * w});
    G[v].push_back({u, 2 * w});
  }
  for (int i = 1; i <= n; ++i) scanf("%lld", &val[i]);
  spfa();
  for (int i = 1; i <= n; ++i) printf("%lld ", dis[i]);
  return 0;
}
