#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
stringstream ssin;
const long long LINF = 0x7fffffffffffffffll;
const long long N = 1e6 + 5, M = 2e6 + 5, mod = 1e9 + 7, INF = 0x3f3f3f3f;
long long n, m, idx;
long long e[M], ne[M], w[M], h[N];
long long a[N], d[N];
bool vis[N];
inline long long read() {
  char c = getchar();
  long long x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
void add(long long a, long long b, long long c) {
  e[idx] = b;
  w[idx] = c;
  ne[idx] = h[a];
  h[a] = idx++;
}
void dij() {
  for (int i = 1; i < N; ++i) d[i] = 1e18;
  q.push({0, 0});
  d[0] = 0;
  while (!q.empty()) {
    pair<long long, long long> t = q.top();
    q.pop();
    int u = t.second;
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = h[u]; ~i; i = ne[i]) {
      long long v = e[i], z = w[i];
      if (d[u] + z < d[v]) {
        d[v] = d[u] + z;
        q.push({d[v], v});
      }
    }
  }
}
int main() {
  n = read();
  m = read();
  memset(h, -1, sizeof h);
  ;
  for (int i = 1; i <= m; ++i) {
    long long u, v, w;
    u = read();
    v = read();
    w = read();
    u++;
    v++;
    w = w * 2;
    add(u, v, w);
    add(v, u, w);
  }
  for (int i = 2; i <= n + 1; ++i) {
    a[i] = read();
    add(0, i, a[i]);
    add(i, 0, a[i]);
  }
  dij();
  for (int i = 2; i <= n + 1; ++i) cout << d[i] << " ";
  puts("");
}
