#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, m;
int long long dp[maxn];
vector<pair<int long long, int long long>> veci[maxn];
set<pair<int long long, int long long>> st;
bool mark[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  fill_n(dp, maxn, 1e18);
  while (m--) {
    int long long a, b, c;
    cin >> a >> b >> c;
    veci[a].push_back({b, c});
    veci[b].push_back({a, c});
  }
  for (int i = 1; i <= n; i++) {
    int long long a;
    cin >> a;
    st.insert({a, i});
  }
  while (st.size() > 0) {
    auto x = *st.begin();
    st.erase(x);
    if (mark[x.second]) continue;
    dp[x.second] = x.first;
    mark[x.second] = 1;
    for (auto y : veci[x.second])
      st.insert({dp[x.second] + (2 * y.second), y.first});
  }
  for (int i = 1; i <= n; i++) cout << dp[i] << " ";
}
