#include <bits/stdc++.h>
using namespace std;
void preprocess(void) { return; }
vector<vector<pair<int, long long>>> adj;
vector<long long> dis;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, m;
  cin >> n >> m;
  adj.resize(n + 2, vector<pair<int, long long>>(0));
  for (auto i = (0); i < m; i++) {
    int u, v;
    long long w;
    cin >> u >> v >> w;
    adj[u].push_back({v, 2 * w});
    adj[v].push_back({u, 2 * w});
  };
  vector<long long> a(n + 1);
  for (auto i = (0); i < n; i++) cin >> a[i + 1];
  ;
  for (auto i = (1); i < n + 1; i++) {
    adj[i].push_back({n + 1, a[i]});
    adj[n + 1].push_back({i, a[i]});
  };
  priority_queue<pair<long long, long long>> pq;
  dis.resize(n + 2, 1000000007 * 1LL * 1000000007);
  dis[n + 1] = 0;
  pq.push({0, n + 1});
  vector<int> vis(n + 2);
  while (!pq.empty()) {
    auto x = pq.top();
    x.first = -x.first;
    if (vis[x.second] == 1) {
      pq.pop();
      continue;
    }
    vis[x.second] = 1;
    ;
    pq.pop();
    for (auto y : adj[x.second]) {
      if (!vis[y.first]) {
        if (dis[y.first] > x.first + y.second) {
          dis[y.first] = x.first + y.second;
          pq.push({-dis[y.first], y.first});
        }
      }
    }
  }
  for (auto i = (1); i < n + 1; i++) cout << dis[i] << " ";
  cout << endl;
}
