#include <bits/stdc++.h>
using namespace std;
long long n, m, dis[400005], vis[400005];
struct road {
  long long v, w;
  bool operator<(const road &b) const { return w > b.w; }
  road(long long ax, long long ay) {
    v = ax;
    w = ay;
  }
  road() {}
};
vector<road> t[400005];
priority_queue<road> q;
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= m; i++) {
    long long u, v, w;
    scanf("%lld%lld%lld", &u, &v, &w);
    t[u].push_back(road(v, w * 2));
    t[v].push_back(road(u, w * 2));
  }
  for (long long i = 1; i <= n; i++) {
    long long w;
    scanf("%lld", &w);
    t[0].push_back(road(i, w));
    dis[i] = 1e18 + 9;
  }
  m += n;
  q.push(road(0, 0));
  while (!q.empty()) {
    long long x = q.top().v;
    q.pop();
    if (vis[x]) {
      continue;
    }
    vis[x] = 1;
    for (long long i = 0; i < t[x].size(); i++) {
      long long y = t[x][i].v;
      if (dis[y] > dis[x] + t[x][i].w) {
        dis[y] = dis[x] + t[x][i].w;
        q.push(road(y, dis[y]));
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << dis[i] << endl;
  }
  return 0;
}
