#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<pair<long long, int> > E[N];
long long dis[N];
bool vis[N];
int n, m;
void Dij() {
  memset(dis, 0x3f, sizeof(dis));
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      q;
  q.push(pair<long long, int>(0, 0));
  dis[0] = 0;
  while (!q.empty()) {
    pair<long long, int> f = q.top();
    q.pop();
    if (vis[f.second]) continue;
    vis[f.second] = 1;
    for (auto i : E[f.second]) {
      int t = i.second;
      long long w = i.first;
      if (!vis[t]) {
        if (dis[t] > dis[f.second] + w) {
          dis[t] = dis[f.second] + w;
          q.push(pair<long long, int>(dis[t], t));
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%I64d%c", dis[i], (i == n) ? '\n' : ' ');
}
int main() {
  scanf("%d%d", &n, &m);
  int f, t;
  long long w;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%I64d", &f, &t, &w);
    E[f].push_back(pair<long long, int>(2 * w, t));
    E[t].push_back(pair<long long, int>(2 * w, f));
  }
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &w);
    E[0].push_back(pair<long long, int>(w, i + 1));
  }
  Dij();
  return 0;
}
