#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head


template<typename T>
struct Dijkstra{
  typedef pair<int,T> pit;
  typedef pair<T,int> pti;  
  const T INFT;
  vector<vector<pit> > G;
  vector<T> dist;
  int n;
  Dijkstra( T INFT ) : INFT(INFT) {}
  void init( int arg_n ){
    n = arg_n;
    G = vector<vector<pit> >( n , vector<pit>(0) );
  }
  void add_biedge( int fr , int to , T co ){
    G[fr].pb( to , co );
    G[to].pb( fr , co );
  }
  void add_edge( int fr , int to , T co ){
    G[fr].pb( to , co );
  }
  T dijkstra( int s , int t = -1 ){
    dist = vector<T>( n , INFT );
    dist[s] = 0;
    priority_queue<pti,vector<pti>,greater<pti> > que;
    que.emplace( 0 , s );
    while( !que.empty() ){
      T d = que.top().fi;
      int p = que.top().se;
      que.pop();
      if( d > dist[p] ){
	continue;
      }
      if( p == t ){
	return d;
      }
      YYS( w , G[p] ){
	int to = w.fi;
	T co = w.se;
	if( d + co < dist[to] ){
	  dist[to] = d + co;
	  que.emplace( dist[to] , to );
	}
      }
    }
    return INFT;
  }
};

Dijkstra<int> dij(INF);

int n, m, l;

int p( int pos , int mon ){
  assert( 0 <= mon && mon <= l );
  return pos * ( l + 1 ) + mon;
}

int main(){

  while( 1 ){
    n = in();
    m = in();
    l = in();
    if( n == 0 && m == 0 && l == 0 ){
      break;
    }
    dij.init( n * ( l + 1 ) );
    REP( cnt , m ){
      int a = in() - 1;
      int b = in() - 1;
      int d = in();
      int e = in();
      REP( i , l+1 ){
        dij.add_edge( p( a , i ) , p( b , i ) , e );
        dij.add_edge( p( b , i ) , p( a , i ) , e );
        if( i - d >= 0 ){
          dij.add_edge( p( a , i ) , p( b , i-d ) , 0 );
          dij.add_edge( p( b , i ) , p( a , i-d ) , 0 );
        }
      }
    }
    REP( i , n ){
      REP( j , l ){
        dij.add_edge( p( i , j+1 ) , p( i , j ) , 0 );
      }
    }
    printf( "%d\n" , dij.dijkstra( p( 0 , l ) , p( n-1 , 0 ) ) );
  }
  
  return 0;
}

Measured memory_bytes: 8248