#include <bits/stdc++.h>
using namespace std;
int const N = 200020;
int nodes, edge;
vector<tuple<int, long long, bool> > graph[N];
priority_queue<pair<long long, int> > q;
long long cost[N], best[N];
bool vis[N];
void dfs() {
  while (!q.empty()) {
    int node = q.top().second;
    long long curr = -q.top().first;
    q.pop();
    if (vis[node]) continue;
    vis[node] = 1;
    for (int i = 0; i < graph[node].size(); i++) {
      tuple<int, long long, bool> el = graph[node][i];
      if (2 * get<1>(el) + curr < best[get<0>(el)]) {
        best[get<0>(el)] = 2 * get<1>(el) + curr;
        q.push(make_pair(-best[get<0>(el)], get<0>(el)));
      }
    }
  }
}
int main() {
  scanf("%d%d", &nodes, &edge);
  for (int i = 0; i < edge; i++) {
    int temp, temp1;
    long long c;
    scanf("%d%d%lld", &temp, &temp1, &c);
    temp--;
    temp1--;
    graph[temp].push_back(make_tuple(temp1, c, 0));
    graph[temp1].push_back(make_tuple(temp, c, 0));
  }
  for (int i = 0; i < nodes; i++) {
    scanf("%lld", best + i);
    q.push(make_pair(-best[i], i));
  }
  dfs();
  for (int i = 0; i < nodes; i++) {
    printf("%lld ", best[i]);
  }
  return 0;
}
