#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int MAXN=200010;
typedef long long ll;
int n,m;
ll d[MAXN],x;
struct edge
{
int to;
ll cost;
edge(int to,ll cost):to(to),cost(cost){}
};
vector<edge>G[MAXN];
typedef pair<ll,int>P;
inline int read()
{
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9')s=s*10+(ch-'0'),ch=getchar();
return s*w;
}
inline ll read_ll()
{
ll s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9')s=s*10+(ch-'0'),ch=getchar();
return s*w;
}
void dij(int s)
{
priority_queue<P,vector<P>,greater<P> >q;
for(register int i=1;i<=n;i++) d[i]=0x3f3f3f3f;
d[s]=0;
q.push(make_pair(0,s));
while(!q.empty())
{
P p=q.top();
q.pop();
int v=p.second;
if(d[v]<p.first) continue;
for(register int i=0;i<G[v].size();i++)
{
edge e=G[v][i];
if(d[e.to]>d[v]+e.cost)
{
d[e.to]=d[v]+e.cost;
q.push(make_pair(d[e.to],e.to));
}
}
}
}
int main()
{
n=read(),m=read();
while(m--)
{
int u=read(),v=read();
ll w=read_ll();
G[u].push_back(edge(v,w*2));
G[v].push_back(edge(u,w*2));
}
for(register int i=1;i<=n;i++) G[0].push_back(edge(i,read_ll()));
dij(0);
for(register int i=1;i<=n;i++) printf("%lld ",d[i]);
return 0;
}