#include <bits/stdc++.h>
using namespace std;
inline long long mi(long long a, long long b) { return a > b ? b : a; }
inline long long ma(long long a, long long b) { return a > b ? a : b; }
long long ans[200005], val[200005];
bool vis[200005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long>> adj[200005];
  for (long long(i) = (0); (i) < (m); (i)++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    adj[a].push_back({b, c});
    adj[b].push_back({a, c});
  }
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  for (long long(i) = (0); (i) < (n); (i)++) {
    cin >> val[i];
    pq.push({val[i], i});
    ans[i] = val[i];
  }
  while (!pq.empty()) {
    pair<long long, long long> cur = pq.top();
    pq.pop();
    if (vis[cur.second]) continue;
    vis[cur.second] = true;
    for (auto xd : adj[cur.second]) {
      if (cur.first + 2 * xd.second < ans[xd.first]) {
        ans[xd.first] = cur.first + 2 * xd.second;
        pq.push({ans[xd.first], xd.first});
      }
    }
  }
  for (long long(i) = (0); (i) < (n); (i)++) cout << ans[i] << endl;
  return 0;
}
