n,m,C=map(int,input().split()) e=[[] for i in range(n*2)] for _ in range(m): u,v,w=map(int,input().split()) u-=1 v-=1 e[u]+=[(v,w+C)] e[v]+=[(u,w+C)] e[n+u]+=[(n+v,w+C)] e[n+v]+=[(n+u,w+C)] e[n+u]+=[(v,C)] e[n+v]+=[(u,C)] from heapq import heappush,heappop X=10**20 v=[X]*n*2 v[n+n-1]=0 q=[(v[n+n-1],n+n-1)] while len(q)>0: sc,sp=heappop(q) if sc>v[sp]: continue for tp,tc in e[sp]: if v[tp]>sc+tc: v[tp]=sc+tc heappush(q,(v[tp],tp)) v1=v[:] v=[X]*n*2 v[0]=0 q=[(v[0],0)] while len(q)>0: sc,sp=heappop(q) if sc>v[sp]: continue for tp,tc in e[sp]: if v[tp]>sc+tc: v[tp]=sc+tc heappush(q,(v[tp],tp)) v2=v[:] for i in range(1,n): print(min(v2[i]+v1[i],v2[n-1]))