#include <bits/stdc++.h>
using namespace std;
const int N = 200050;
set<pair<long long, int> > ord;
vector<pair<int, long long> > E[N];
long long sol[N];
int main() {
  int n, m, u, v, i;
  long long w;
  scanf("%i %i", &n, &m);
  while (m--) {
    scanf("%i %i %lld", &u, &v, &w);
    w *= 2;
    E[u].push_back(make_pair(v, w));
    E[v].push_back(make_pair(u, w));
  }
  for (i = 1; i <= n; i++)
    scanf("%lld", &sol[i]), ord.insert(make_pair(sol[i], i));
  while (!ord.empty()) {
    u = ord.begin()->second;
    ord.erase(ord.begin());
    for (i = 0; i < E[u].size(); i++) {
      v = E[u][i].first;
      w = E[u][i].second;
      if (sol[v] > sol[u] + w) {
        ord.erase(make_pair(sol[v], v));
        sol[v] = sol[u] + w;
        ord.insert(make_pair(sol[v], v));
      }
    }
  }
  for (i = 1; i <= n; i++) printf("%lld ", sol[i]);
  printf("\n");
  return 0;
}
