#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e9 + 10;
const long long linf = (long long)1e18 + 10;
const long long mod = (long long)(1e9 + 7);
const long long dx[] = {0, 1, 0, -1};
const long long dy[] = {1, 0, -1, 0};
const long long ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;
struct oreno_initializer {
  oreno_initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} oreno_initializer;
long long n, m, l, r, c, a[200200], d[200200];
vector<pair<long long, long long>> e[200200];
void dijkstra(vector<pair<long long, long long>> g[]) {
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  for (long long(i) = (0); (i) < (n); ++(i)) d[i] = a[i], que.push({a[i], i});
  while (!que.empty()) {
    pair<long long, long long> p = que.top();
    que.pop();
    long long v = p.second, dis = p.first;
    if (d[v] < dis) continue;
    for (long long i = 0; i < g[v].size(); ++i) {
      long long to = g[v][i].first, cost = g[v][i].second;
      if (d[to] > d[v] + cost) {
        d[to] = d[v] + cost;
        que.push(make_pair(d[to], to));
      }
    }
  }
}
signed main() {
  cin >> n >> m;
  for (long long(i) = (0); (i) < (m); ++(i)) {
    cin >> l >> r >> c;
    l--, r--, c *= 2;
    e[l].push_back({r, c}), e[r].push_back({l, c});
  }
  for (long long(i) = (0); (i) < (n); ++(i)) cin >> a[i];
  dijkstra(e);
  for (long long(i) = (0); (i) < (n); ++(i))
    cout << d[i] << (i == n - 1 ? '\n' : ' ');
}
