#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
const int NMax = 2e5 + 5;
const ll inf = 1e18 + 5;
const int mod = 100003;
using zint = int;
int N, M;
ll dist[NMax];
vector<pair<int, ll> > v[NMax];
struct cmp {
  bool operator()(pair<int, ll> a, pair<int, ll> b) {
    return a.second > b.second;
  }
};
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 1; i <= M; ++i) {
    int x, y;
    ll c;
    cin >> x >> y >> c;
    v[x].push_back({y, 2 * c});
    v[y].push_back({x, 2 * c});
  }
  priority_queue<pair<int, ll>, vector<pair<int, ll> >, cmp> pq;
  for (int i = 1; i <= N; ++i) {
    ll d;
    cin >> d;
    v[0].push_back({i, d});
    dist[i] = inf;
  }
  dist[0] = 0;
  pq.push({0, 0});
  while (pq.size()) {
    int node = pq.top().first;
    ll d = pq.top().second;
    pq.pop();
    if (dist[node] < d) {
      continue;
    }
    for (auto p : v[node]) {
      int nxt = p.first;
      ll d = p.second;
      if (dist[nxt] <= dist[node] + d) {
        continue;
      }
      dist[nxt] = dist[node] + d;
      pq.push({nxt, dist[nxt]});
    }
  }
  for (int i = 1; i <= N; ++i) {
    cout << dist[i] << ' ';
  }
  return 0;
}
