import heapq N,M,X=map(int,input().split()) G=[{} for i in range(N)] for j in range(M): u,v,c,t=map(int,input().split()) u-=1 v-=1 G[u][v]=(c,t) G[v][u]=(c,t) def dijkstra(s,g): cost=[float("inf")]*N prev=[None]*N cost[s]=0 Q=[(0,s)] heapq.heapify(Q) while Q: d,v=heapq.heappop(Q) if d>cost[v]: continue for u in G[v]: c,t=G[u][v] #(かかる時間)=c/X+t money=c+X*t if cost[v]+money