#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const double eps = 1e-9;
const int inf = 1e9;
long long a[N];
long long dis[N];
int n, m;
vector<pair<int, long long> > adj[N];
void dij() {
  set<pair<long long, int> > q;
  for (int i = 1; i <= n; i++) {
    dis[i] = a[i];
    q.insert({dis[i], i});
  }
  while (q.size()) {
    int u = q.begin()->second;
    q.erase(q.begin());
    for (auto i : adj[u]) {
      long long ww = i.second;
      int v = i.first;
      if (dis[v] > dis[u] + ww) {
        q.erase({dis[v], v});
        dis[v] = dis[u] + ww;
        q.insert({dis[v], v});
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    w *= 2;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  for (int i = 1; i <= n; i++) scanf("%lld", a + i);
  dij();
  for (int i = 1; i <= n; i++) printf("%lld ", dis[i]);
}
