#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long> > g[200005];
long long d[200005];
bool cmp(int a, int b) { return d[a] != d[b] ? d[a] < d[b] : a < b; }
set<int, bool (*)(int, int)> q(cmp);
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    long long c;
    cin >> a >> b >> c;
    --a, --b;
    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
    q.insert(i);
  }
  while (!q.empty()) {
    int v = *q.begin();
    q.erase(q.begin());
    for (auto to : g[v]) {
      long long len = to.second;
      int z = to.first;
      if (d[v] + len * 2 < d[z]) {
        q.erase(z);
        d[z] = d[v] + len * 2;
        q.insert(z);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << d[i] << " ";
  }
}
