#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define loop(i,a,n) for(int i=a;i<n;++i)
#define arrin(arr,n) for(int i=0; i < n; ++i) cin>>arr[i];
#define arrout(arr,n) for(int i=0; i < n; ++i) cout<<arr[i]<<" ";cout<<nl;
#define nl "\n"
#define ff first
#define ss second
#define _USE_MATH_DEFINES
// M_E : e  M_PI :pi  M_SQRT2:sqrt(2)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
struct compare 
{
  bool operator()(const int& l, const int& r) 
  {
      return l > r; //min: > ; max: <
  }
};
  
using namespace std;
priority_queue<int,vector<int>, compare > pq;

ll mc[200001],cost[200001],vis[200001];
vector <vector <pair<int,ll> > > g(200001);

ll dfs (int curr)
{
	vis[curr]=1;
	//mc[curr]=cost[curr];
	for (auto x: g[curr])
	{
		//if (curr==1)
		//	cout <<x.ff<<" ";
		if (vis[x.ff])
		{
			mc[curr]=min(mc[curr],2*x.ss+mc[x.ff]);
		//	cout <<mc[curr]<<nl;
		}
		else
		{
			mc[curr]=min(mc[curr],2*x.ss+dfs(x.ff));
		//	cout <<mc[curr]<<nl;

		}
	}
	for (auto x: g[curr])
	{
		mc[x.ff]=min(mc[x.ff],2*x.ss+mc[curr]);
	}
	return mc[curr];
}

int main()
{
  fastio();
  int n,m;
  cin >>n >>m;
  loop (i,0,m)
  {
  	ll u,v,w;
  	cin >>u >>v >>w;
  	g[u].pb(mp(v,w));
  	g[v].pb(mp(u,w));
  }
  memset (mc,-1,sizeof(mc));
  memset (vis,0,sizeof(vis));
  loop (i,0,n)
  {
  	cin >>mc[i+1];
  	//mc[i+1]=cost[i+1];
  }
  
  for (int i=1; i<=n; i++)
  {
  	if (!vis[i])
  		dfs(i);
  }
  for (int i=1; i<=n; i++)
  	cout <<mc[i]<<" ";
}