#include <bits/stdc++.h>
long long Qread() {
  long long X = 0;
  char C = getchar();
  while (C > '9' || C < '0') C = getchar();
  while (C >= '0' && C <= '9') {
    X = X * 10 + C - '0';
    C = getchar();
  }
  return X;
}
const long long Maxn = 2e5 + 5, Maxm = 2e5 + 5;
long long N, M, Head[Maxn], En = 0;
long long Vis[Maxn], Mdis[Maxn];
struct Edge {
  long long Goto, Next;
  long long Len;
};
Edge E[Maxm << 2];
void Add(long long X, long long Y, long long L) {
  E[++En].Goto = Y;
  E[En].Len = L;
  E[En].Next = Head[X];
  Head[X] = En;
}
struct Dis {
  long long X, Len;
};
bool operator<(const Dis& A, const Dis& B) { return A.Len > B.Len; }
std ::priority_queue<Dis> Q;
Dis Make(long long X, long long Len) {
  Dis Ans;
  Ans.Len = Len, Ans.X = X;
  return Ans;
}
void Dijkstra() {
  memset(Mdis, 0x3f, sizeof(Mdis)), memset(Vis, 0, sizeof(Vis));
  Q.push(Make(0, 0));
  Mdis[0] = 0;
  while (!Q.empty()) {
    Dis Now = Q.top();
    Q.pop();
    if (Vis[Now.X]) continue;
    Vis[Now.X] = 1;
    for (long long i = Head[Now.X]; i; i = E[i].Next) {
      long long Ndis = Mdis[Now.X] + E[i].Len;
      if (Ndis < Mdis[E[i].Goto]) {
        Mdis[E[i].Goto] = Ndis;
        Q.push(Make(E[i].Goto, Ndis));
      }
    }
  }
}
signed main() {
  N = Qread(), M = Qread();
  memset(Head, 0, sizeof(Head)), En = 0;
  for (long long i = 1; i <= M; ++i) {
    long long X = Qread(), Y = Qread(), L = Qread();
    Add(X, Y, L << 1), Add(Y, X, L << 1);
  }
  for (long long i = 1; i <= N; ++i) {
    long long K = Qread();
    Add(0, i, K);
  }
  Dijkstra();
  for (long long i = 1; i <= N; ++i) printf("%I64d ", Mdis[i]);
  fclose(stdin), fclose(stdout);
  return 0;
}
