#include <bits/stdc++.h>
std::vector<int> a[200005];
std::vector<long long> b[200005];
int n, m, vis[200005], s;
long long dis[200005];
void add(int x, int y, long long v) {
  a[x].push_back(y);
  b[x].push_back(v);
}
void dijkstra(int s) {
  std::priority_queue<std::pair<long long, int> > pq;
  for (int i = 1; i <= n + 1; i++) vis[i] = 0, dis[i] = 1000000000000000000;
  dis[s] = 0;
  pq.push(std::make_pair(-dis[s], s));
  while (!pq.empty()) {
    int v = pq.top().second;
    pq.pop();
    if (vis[v]) continue;
    vis[v] = 1;
    for (int i = 0; i < a[v].size(); i++) {
      int u = a[v][i];
      long long w = b[v][i];
      if (dis[v] + w < dis[u])
        dis[u] = dis[v] + w, pq.push(std::make_pair(-dis[u], u));
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  s = n + 1;
  for (int i = 1; i <= m; i++) {
    int x, y;
    long long v;
    scanf("%d%d%lld", &x, &y, &v);
    add(x, y, v * 2);
    add(y, x, v * 2);
  }
  for (int i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    add(s, i, x);
  }
  dijkstra(s);
  for (int i = 1; i <= n; i++) printf("%lld ", dis[i]);
  puts("");
  return 0;
}
