#include <bits/stdc++.h>
using namespace std;
const long long maxn = 400010;
long long n, m, first[maxn], v[maxn], nextt[maxn], w[maxn], tot = 1, vis[maxn],
                                                            ans[maxn];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
void add(long long x, long long y, long long z) {
  w[tot] = z;
  v[tot] = y;
  nextt[tot] = first[x];
  first[x] = tot++;
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= m; i++) {
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    add(a, b, 2 * c);
    add(b, a, 2 * c);
  }
  for (long long i = 1; i <= n; i++) {
    long long t;
    scanf("%lld", &t);
    q.push(make_pair(t, i));
  }
  while (!q.empty()) {
    pair<long long, long long> u = q.top();
    q.pop();
    if (vis[u.second]) continue;
    vis[u.second] = 1;
    ans[u.second] = u.first;
    for (long long e = first[u.second]; e; e = nextt[e]) {
      q.push(make_pair(u.first + w[e], v[e]));
    }
  }
  for (long long i = 1; i <= n; i++) printf("%lld ", ans[i]);
  return 0;
}
