#include <bits/stdc++.h>
using namespace std;
long long ans[200005];
vector<pair<int, long long> > edge[200005];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
bool vis[200005];
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    ans[i] = 2000000000000000001;
  }
  for (i = 1; i <= m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    edge[u].push_back(make_pair(v, w << 1));
    edge[v].push_back(make_pair(u, w << 1));
  }
  for (i = 1; i <= n; i++) {
    long long w;
    scanf("%lld", &w);
    edge[n + 1].push_back(make_pair(i, w));
  }
  q.push(make_pair(0, n + 1));
  while (!q.empty()) {
    int t = q.top().second;
    q.pop();
    if (vis[t]) {
      continue;
    }
    vis[t] = 1;
    for (i = 0; i < edge[t].size(); i++) {
      ans[edge[t][i].first] =
          min(ans[edge[t][i].first], ans[t] + edge[t][i].second);
      q.push(make_pair(ans[edge[t][i].first], edge[t][i].first));
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%lld ", ans[i]);
  }
  return 0;
}
