#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
struct node {
  pair<long long, long long> x;
  long long y;
  node* l = nullptr;
  node* r = nullptr;
  node(pair<long long, long long> x) : x(x) { y = rand(); }
};
node* merge(node* a, node* b) {
  if (a == nullptr) return b;
  if (b == nullptr) return a;
  if (a->y > b->y) {
    a->r = merge(a->r, b);
    return a;
  }
  b->l = merge(a, b->l);
  return b;
}
pair<node*, node*> split(node* a, pair<long long, long long> b) {
  if (a == nullptr) return {nullptr, nullptr};
  if (a->x <= b) {
    pair<node*, node*> tmp = split(a->r, b);
    a->r = tmp.first;
    return {a, tmp.second};
  } else {
    pair<node*, node*> tmp = split(a->l, b);
    a->l = tmp.second;
    return {tmp.first, a};
  }
}
pair<long long, long long> getmin(node* a) {
  if (a->l == nullptr) return a->x;
  return getmin(a->l);
}
node* add(node* a, pair<long long, long long> x) {
  pair<node*, node*> tmp = split(a, x);
  node* b = new node(x);
  tmp.first = merge(tmp.first, b);
  tmp.second = merge(tmp.first, tmp.second);
  return tmp.second;
}
node* pop(node* a, pair<long long, long long> x) {
  if (a->x == x) {
    a = merge(a->l, a->r);
    return a;
  }
  if (a->x > x) {
    a->l = pop(a->l, x);
  } else {
    a->r = pop(a->r, x);
  }
  return a;
}
signed main() {
  node* s = nullptr;
  long long n, m;
  cin >> n >> m;
  vector<vector<pair<long long, long long>>> a(n);
  for (long long i = 0; i < m; ++i) {
    long long x, y, v;
    cin >> x >> y >> v;
    a[x - 1].emplace_back(y - 1, 2 * v);
    a[y - 1].emplace_back(x - 1, 2 * v);
  }
  vector<long long> d(n);
  for (long long i = 0; i < n; ++i) {
    cin >> d[i];
    s = add(s, {d[i], i});
  }
  for (long long _ = 0; _ < n; ++_) {
    pair<long long, long long> now = getmin(s);
    s = pop(s, now);
    for (auto i : a[now.second]) {
      if (d[i.first] > d[now.second] + i.second) {
        s = pop(s, {d[i.first], i.first});
        d[i.first] = d[now.second] + i.second;
        s = add(s, {d[i.first], i.first});
      }
    }
  }
  for (long long i : d) {
    cout << i << " ";
  }
  return 0;
}
