#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;

#define INF (1<<20)
typedef pair< int , int > P;
typedef pair< int , P > Pi;
struct Edge {
  int to,cost,des;
  Edge(){}
  Edge(int to,int cost,int des):to(to),cost(cost),des(des){};
};
vector< vector< Edge > > Graph;
int V,E,L;

int Dijkstra(int s,int g) {
  int min_cost[111][111];
  fill_n(*min_cost,111*111,INF);
  priority_queue < Pi ,vector< Pi >,greater< Pi > > que;
  que.push(Pi(0,P(L,s)));
  min_cost[s][L] = 0;
  while(!que.empty()){
    int cost = que.top().first;
    int des = que.top().second.first;
    int now = que.top().second.second;
    que.pop();
    if(now == g) return cost;
    if(cost > min_cost[now][des]) continue;
    for(int i=0;i<Graph[now].size();i++){
      Edge e = Graph[now][i];
      if(des >= e.des && min_cost[e.to][des-e.des] > cost){
	min_cost[e.to][des-e.des] = cost;
	que.push(Pi(cost,P(des-e.des,e.to)));
      }
      if(min_cost[e.to][des] > cost + e.cost){
	min_cost[e.to][des] = cost + e.cost;
	que.push(Pi(min_cost[e.to][des],P(des,e.to)));
      }
    }
  }
  return (-1);
}

int main(){
  while(cin >> V >> E >> L , (V||E||L)){
    Graph.resize(V+1);
    for(int i=0;i<E;i++){
      int a,b,c,d;
      cin >> a >> b >> c >> d;
      a--; b--;
      Graph[a].push_back(Edge(b,d,c));
      Graph[b].push_back(Edge(a,d,c));
    }
    cout << Dijkstra(0,V-1) << endl;
    Graph.clear();
  }
}