#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long quickpow(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2) ans = ans * a;
    b = b / 2;
    a = a * a;
  }
  return ans;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
long long n, m, head[200005], to[200005 * 2], nxt[200005 * 2];
long long w[200005 * 2], tot = 1;
long long vis[200005], ans[200005];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
void addedge(long long u, long long v, long long val) {
  w[tot] = val;
  to[tot] = v;
  nxt[tot] = head[u];
  head[u] = tot++;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    addedge(a, b, 2 * c);
    addedge(b, a, 2 * c);
  }
  for (long long i = 1; i <= n; i++) {
    long long t;
    cin >> 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 i = head[u.second]; i; i = nxt[i]) {
      long long v = to[i];
      q.push(make_pair(u.first + w[i], v));
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
}
