from heapq import heappop, heappush N, M, C = map(int, input().split()) g = [[] for _ in range(N)] for _ in range(M): u, v, w = map(int, input().split()) u, v = u - 1, v - 1 g[u].append((v, w)) g[v].append((u, w)) INF = 1 << 60 cost_fr0 = [INF] * N cost_fr0[0] = 0 hq = [(0, 0)] while hq: c, u = heappop(hq) if cost_fr0[u] < c: continue for v, w in g[u]: if cost_fr0[v] > c + w + C: cost_fr0[v] = c + w + C heappush(hq, (c + w + C, v)) cost_frN = [[INF] * N for _ in range(2)] cost_frN[0][N - 1] = 0 hq = [(0, 0, N - 1)] while hq: c, t, u = heappop(hq) if cost_frN[t][u] > c: continue for v, w in g[u]: if t == 0 and cost_frN[1][v] > c + C: cost_frN[1][v] = c + C heappush(hq, (c + C, 1, v)) if cost_frN[t][v] > c + C + w: cost_frN[t][v] = c + C + w heappush(hq, (c + C + w, t, v)) ans = cost_fr0[N - 1] for i in range(1, N - 1): print(min(ans, cost_fr0[i] + cost_frN[1][i])) print(ans)