#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
vector<long long int> g[N], e[N];
set<pair<long long int, long long int> > S;
int n, m;
long long int d[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    long long int x, y, z;
    cin >> x >> y >> z;
    g[x].push_back(y);
    e[x].push_back(z);
    g[y].push_back(x);
    e[y].push_back(z);
  }
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    S.insert(make_pair(d[i], i));
  }
  while (S.size() != 0) {
    int u = S.begin()->second;
    S.erase(S.begin());
    for (int i = 0; i < g[u].size(); i++) {
      long long int v = g[u][i];
      long long int cost = e[u][i];
      if (cost * 2 + d[u] < d[v]) {
        S.erase(make_pair(d[v], v));
        d[v] = cost * 2 + d[u];
        S.insert(make_pair(d[v], v));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << d[i] << ' ';
  }
  return 0;
}
