#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int to[N << 2], nex[N << 2], beg[N], cnt;
long long w[N << 2], a[N], dis[N];
int vis[N];
int n, m;
void addedge(int u, int v, long long wt) {
  to[++cnt] = v;
  nex[cnt] = beg[u];
  w[cnt] = wt;
  beg[u] = cnt;
}
void dijkstra(int u) {
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      q;
  dis[u] = 0;
  q.push(pair<long long, long long>(0, u));
  while (!q.empty()) {
    pair<long long, long long> tmp = q.top();
    q.pop();
    if (vis[tmp.second] == 1) {
      continue;
    }
    vis[tmp.second] = 1;
    for (int i = beg[tmp.second]; i; i = nex[i]) {
      int v = to[i];
      if (dis[v] > dis[tmp.second] + w[i]) {
        dis[v] = dis[tmp.second] + w[i];
        q.push(pair<long long, long long>(dis[v], v));
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    addedge(u, v, w * 2);
    addedge(v, u, w * 2);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a + i);
    addedge(0, i, a[i]);
  }
  memset(dis, 0x3f, sizeof(dis));
  dijkstra(0);
  for (int i = 1; i <= n; i++) {
    printf("%lld ", dis[i]);
  }
}
