#include <bits/stdc++.h>
using namespace std;
struct node;
typedef pair<unsigned long long, node*> wn;
struct node {
  vector<wn> chs;
  unsigned long long w;
};
const int maxn = 2e5;
node nds[maxn];
bool vst[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    unsigned long long w;
    cin >> u >> v >> w;
    nds[u - 1].chs.push_back(wn(w, nds + v - 1));
    nds[v - 1].chs.push_back(wn(w, nds + u - 1));
  }
  priority_queue<wn, vector<wn>, greater<wn> > q;
  for (int i = 0; i < n; i++) {
    cin >> nds[i].w;
    q.push(wn(nds[i].w, nds + i));
  }
  while (!q.empty()) {
    node* u = q.top().second;
    q.pop();
    if (vst[u - nds]) continue;
    vst[u - nds] = true;
    for (auto wni : u->chs) {
      unsigned long long w = wni.first;
      node* v = wni.second;
      unsigned long long tw = 2 * w + u->w;
      if (tw < v->w) {
        v->w = tw;
        q.push(wn(v->w, v));
      }
    }
  }
  for (int i = 0; i < n; i++) cout << nds[i].w << " ";
  cout << endl;
}
