#include <bits/stdc++.h>
using namespace std;
const int N = 200 * 1000 + 13;
int n, m;
vector<pair<int, long long>> g[N];
void Dijkstra(vector<long long> &a, vector<long long> &dist) {
  set<pair<long long, int>> q;
  for (int i = 0; i < int(n); i++) {
    dist[i] = a[i];
    q.insert({dist[i], i});
  }
  while (!q.empty()) {
    int v = q.begin()->second;
    q.erase(q.begin());
    for (auto it : g[v]) {
      int u = it.first;
      long long w = it.second;
      if (dist[u] > dist[v] + w) {
        q.erase({dist[u], u});
        dist[u] = dist[v] + w;
        q.insert({dist[u], u});
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int _ = 0; _ < int(m); _++) {
    int f, t;
    long long w;
    cin >> f >> t >> w;
    --f, --t;
    w *= 2;
    g[f].push_back({t, w});
    g[t].push_back({f, w});
  }
  vector<long long> a(n + 1);
  for (int i = 0; i < int(n); i++) {
    cin >> a[i];
  }
  vector<long long> dist(n + 1);
  Dijkstra(a, dist);
  for (int i = 0; i < int(n); i++) cout << dist[i] << " ";
  puts("");
  return 0;
}
