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=[10**19]*(n+1) D[1]=0 q=[] heapq.heappush(q,(0,1)) while q: d,x=heapq.heappop(q) for e,a,b in E[x]: if y<=b and D[x]+a