#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const long long inf = (long long)1e18;
int n, m, cnt, last[N];
long long dis[N];
bool vis[N];
struct edge {
  int to, next;
  long long w;
} e[N * 4];
priority_queue<pair<long long, int> > que;
void addedge(int u, int v, long long w) {
  e[++cnt].to = v;
  e[cnt].w = w;
  e[cnt].next = last[u];
  last[u] = cnt;
  e[++cnt].to = u;
  e[cnt].w = w;
  e[cnt].next = last[v];
  last[v] = cnt;
}
void dij() {
  for (int i = 1; i <= n; i++) dis[i] = inf;
  que.push(make_pair(0, 0));
  while (!que.empty()) {
    int x = que.top().second;
    que.pop();
    while (!que.empty() && vis[x]) x = que.top().second, que.pop();
    if (vis[x]) break;
    vis[x] = 1;
    for (int i = last[x]; i; i = e[i].next)
      if (dis[x] + e[i].w < dis[e[i].to]) {
        dis[e[i].to] = dis[x] + e[i].w;
        que.push(make_pair(-dis[e[i].to], e[i].to));
      }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    long long z;
    scanf("%d%d%I64d", &x, &y, &z);
    addedge(x, y, z * 2);
  }
  for (int i = 1; i <= n; i++) {
    long long w;
    scanf("%I64d", &w);
    addedge(0, i, w);
  }
  dij();
  for (int i = 1; i <= n; i++) printf("%I64d ", dis[i]);
  return 0;
}
