#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#define N 200010
using namespace std;
int n,m;
int fir[N],nex[N*2],poi[N*2],sum;
long long w[N*2],d[N];
bool v[N];
struct Node{
int x;long long dis;
bool operator < (const Node &a)
const {return dis>a.dis;}
} s;
priority_queue<Node> q;
void re(int &x)
{
x=0;char i=getchar();
while(i<'0'||i>'9') i=getchar();
while(i>='0'&&i<='9') x=(x<<1)+(x<<3)+i-'0',i=getchar();
}
void ins(int x,int y,long long z)
{
nex[++sum]=fir[x];
poi[sum]=y;
w[sum]=z;
fir[x]=sum;
}
void dijistra()
{
q.push({0,0});
memset(d,0x3f,sizeof(d));
d[0]=0;
while(!q.empty())
{
Node k=q.top();q.pop();
if(v[k.x]) continue;
v[k.x]=1;
for(int i=fir[k.x];i;i=nex[i])
{
int p=poi[i];
if(d[p]>d[k.x]+w[i])
{
d[p]=d[k.x]+w[i];
q.push({p,k.dis+w[i]});
}
}
}
}
int main()
{
re(n);re(m);
int x,y;long long z;
for(int i=1;i<=m;i++)
{
re(x);re(y);scanf("%lld",&z);
ins(x,y,z*2);ins(y,x,z*2);
}
for(int i=1;i<=n;i++)
{
scanf("%lld",&z);
ins(0,i,z);
}
dijistra();
for(int i=1;i<=n;i++)
printf("%lld ",d[i]);
return 0;
}