#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 10;
vector<pair<int, long long int>> node[N];
long long int e[N];
bool z[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  long long int x, y, w;
  for (int i = 0; i <= n + 1; i++) node[i].clear();
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> w;
    node[x].push_back({y, 2 * w});
    node[y].push_back({x, 2 * w});
  }
  for (int i = 1; i <= n; i++) {
    cin >> w;
    node[0].push_back({i, w});
  }
  memset(z, 0, sizeof(z));
  for (int i = 0; i <= n; i++) e[i] = 1e18;
  e[0] = 0;
  priority_queue<pair<long long int, int>> q;
  q.push({0, 0});
  while (!q.empty()) {
    long long int a = q.top().second;
    q.pop();
    if (z[a]) continue;
    z[a] = 1;
    for (auto b : node[a]) {
      if (e[a] + b.second < e[b.first]) {
        e[b.first] = e[a] + b.second;
        q.push({-e[b.first], b.first});
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << e[i] << ' ';
  }
}
