import heapq n,m,X=map(int,input().split()) edge=[tuple(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)) for i in range(n+1): E[i].sort(key=lambda x:x[2],reverse=True) def f(w): D=[10**19]*(n+1) D[1]=0 q=[] heapq.heappush(q,(0,1)) while q: d,x=heapq.heappop(q) if x==n:break for e,a,b in E[x]: if w<=b and D[x]+a