from collections import deque import heapq n,m,X=map(int,input().split()) edge=[list(map(int,input().split())) for _ in range(m)] E=[[] for _ in range(n+1)] for u,v,a,b in edge: E[u].append([v,a,b]) E[v].append([u,a,b]) def f(y): D=[float("inf")]*(n+1) D[1]=0 # q=deque([1]) q=[] heapq.heappush(q,(0,1)) while q: # x=q.popleft() d,x=heapq.heappop(q) for e,a,b in E[x]: if y<=b and D[x]+a