#include <bits/stdc++.h>
using namespace std;
vector<pair<int, long long int>> v[300001];
vector<long long int> a(300001);
void bfs(int n) {
  set<pair<long long int, int>> p;
  for (int i = 1; i <= n; i++) {
    p.insert({a[i], i});
  }
  while (!p.empty()) {
    int cor2 = p.begin()->second;
    p.erase(p.begin());
    for (auto x : v[cor2]) {
      int cor = x.first;
      long long int val = x.second;
      if (a[cor] > (a[cor2] + val)) {
        p.erase({a[cor], cor});
        a[cor] = a[cor2] + val;
        p.insert({a[cor], cor});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  scanf("%d %d", &n, &m);
  int x, y;
  long long int k;
  for (int i = 0; i < m; i++) {
    scanf("%d %d %lld", &x, &y, &k);
    k *= 2;
    v[x].push_back({y, k});
    v[y].push_back({x, k});
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  bfs(n);
  for (int i = 1; i <= n; i++) {
    printf("%lld ", a[i]);
  }
}
