#include <bits/stdc++.h>
using namespace std;
struct A {
  int to;
  long long d;
  A() {}
  A(int to, long long d) : to(to), d(d) {}
};
vector<A> G[200005];
long long dis[200005] = {};
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0, x, y; i < m; ++i) {
    long long v;
    scanf("%d%d%lld", &x, &y, &v);
    G[x].push_back(A(y, 2 * v));
    G[y].push_back(A(x, 2 * v));
  }
  queue<int> q;
  bool inq[200005] = {};
  vector<pair<long long, int> > pa;
  for (int i = 1; i <= n; ++i) {
    long long v;
    scanf("%lld", &v);
    pa.push_back({v, i});
    inq[i] = 1;
    dis[i] = v;
  }
  sort(pa.begin(), pa.end());
  for (int i = 0; i < pa.size(); ++i) {
    q.push(pa[i].second);
  }
  while (!q.empty()) {
    int fr = q.front();
    q.pop();
    inq[fr] = 0;
    for (auto re : G[fr]) {
      long long d = dis[fr] + re.d;
      if (d < dis[re.to]) {
        dis[re.to] = d;
        if (!inq[re.to]) {
          inq[re.to] = 1;
          q.push(re.to);
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%lld", dis[i]);
    if (i != n) putchar(' ');
  }
  puts("");
}
