#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  map<int, map<int, long long>> t;
  for (int i = 0; i < m; i++) {
    int u, v;
    long long w;
    scanf("%d %d %lld", &u, &v, &w);
    u--;
    v--;
    t[u].insert(make_pair(v, w));
    t[v].insert(make_pair(u, w));
  }
  priority_queue<pair<long long, int>> p;
  long long ta[200001] = {0};
  for (int i = 0; i < n; i++) {
    long long a;
    scanf("%lld", &a);
    ta[i] = a;
    p.push(make_pair(-a, i));
  }
  int visited[200001] = {0};
  while (!p.empty()) {
    pair<long long, int> firstp = p.top();
    p.pop();
    int num = firstp.second;
    if (!visited[num]) {
      long long vtoprop = ta[num];
      visited[num] = true;
      for (auto it : t[num]) {
        if (!visited[it.first]) {
          long long exta = ta[it.first];
          long long nv = 2 * it.second + vtoprop;
          if (exta > nv) {
            ta[it.first] = nv;
            p.push(make_pair(-nv, it.first));
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ta[i] << " ";
  }
  printf("\n");
}
