#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long> > vec[2 * (int)1e5 + 5];
priority_queue<pair<long long, int> > pq;
long long ans[2 * (int)1e5 + 5];
void update() {
  while (!pq.empty()) {
    int u = pq.top().second;
    long long tempAns = -pq.top().first;
    pq.pop();
    for (int i = 0; i < vec[u].size() && tempAns == ans[u]; i++) {
      int v = vec[u][i].first;
      long long w = 2LL * vec[u][i].second;
      if (ans[v] > ans[u] + w) {
        ans[v] = ans[u] + w;
        pq.push(make_pair(-ans[v], v));
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0, u, v; i < m; i++) {
    long long w;
    scanf("%d %d %lld", &u, &v, &w);
    vec[u].push_back(make_pair(v, w));
    vec[v].push_back(make_pair(u, w));
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &ans[i]);
    pq.push(make_pair(-ans[i], i));
  }
  update();
  for (int i = 1; i <= n; i++) {
    if (i - 1) printf(" ");
    printf("%lld", ans[i]);
  }
  printf("\n");
  return 0;
}
