#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 4;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    pq;
vector<pair<long long, long long> > g[MAXN];
long long n, m, a[MAXN];
bool used[MAXN];
long long dist[MAXN];
int main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    g[x].push_back({y, z});
    g[y].push_back({x, z});
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pq.push({a[i], i});
    dist[i] = a[i];
  }
  while (!pq.empty()) {
    long long u = pq.top().second;
    pq.pop();
    if (used[u]) continue;
    used[u] = 1;
    for (long long i = 0; i < g[u].size(); i++) {
      if (dist[g[u][i].first] > dist[u] + 2 * g[u][i].second) {
        dist[g[u][i].first] = dist[u] + 2 * g[u][i].second;
        pq.push({dist[g[u][i].first], g[u][i].first});
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << dist[i] << " ";
  }
  cout << endl;
  return 0;
}
