#include <iostream>
#include <vector>
#include <queue>
#include <map>
#define fr first
#define sc second
#define INF (1 << 25)
using namespace std;

typedef pair<int,int> P;
typedef pair<P,int> iP;
struct edge{
  int to,dis,enemy; edge(){}
  edge(int to,int dis,int enemy):to(to),dis(dis),enemy(enemy){}
};

int n,m,money;
int costed[128][128];
vector<vector<edge> >info(128);

void init(){
  for(int i=0;i<128;i++){
    for(int j=0;j<128;j++) costed[i][j] = INF;
  }
  info.resize(0); info.resize(128);
}

void add_info(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  info[a].push_back(edge(b,c,d));
  info[b].push_back(edge(a,c,d));
}

int Dijkstra(){
  priority_queue<iP,vector<iP>,greater<iP> > que;
  que.push(iP(P(0,1),money));
  costed[money][1] = 0;
  while(!que.empty()){
    iP p = que.top(); que.pop();
    int now =  p.fr.sc,att = p.fr.fr,mo = p.sc;
    if(now == n) return att;
    for(int i=0;i<info[now].size();i++){
      edge e = info[now][i];
      if(e.enemy + att < costed[mo][e.to]){
	que.push(iP(P(att + e.enemy,e.to),mo));
	costed[mo][e.to] = e.enemy + att;
      }
      if(mo >= e.dis && att < costed[mo-e.dis][e.to]){
	que.push(iP(P(att,e.to),mo-e.dis));
	costed[mo-e.dis][e.to] = att;
      }
    }
  }
}

int main(){
  while(cin >> n >> m >> money,n||m||money){
    init();
    while(m--) add_info();
    cout << Dijkstra() << endl;
  }
}