#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

const int inf = 1e9;

typedef pair<int, int> P;

struct E{
    E(int to, int cost): to(to), cost(cost){}

    int to, cost;
};

int n, m, l;
vector<E> g[10100];
int d[10100];

void add_edge(int p, int a, int q, int b, int e){
    g[p * n + a].push_back(E(q * n + b, e));
}

int dijkstra(){
    fill_n(d, (l + 1) * n, inf);

    priority_queue<P, vector<P>, greater<P>> q;
    d[l * n] = 0;
    q.push(P(0, l * n));
    while(!q.empty()){
        P v = q.top();
        q.pop();
        if(v.first > d[v.second]){
            continue;
        }
        for(E& e: g[v.second]){
            if(d[e.to] > v.first + e.cost){
                d[e.to] = v.first + e.cost;
                q.push(P(d[e.to], e.to));
            }
        }
    }

    int ans = inf;
    rep(i, l + 1){
        ans = min(d[i * n + n - 1], ans);
    }
    return ans;
}

int main(){
    while(1){
        cin >> n >> m >> l;
        
        if(n == 0){
            break;
        }

        rep(i, (l + 1) * n){
            g[i].clear();
        }

        rep(i, m){
            int a, b, d, e;
            cin >> a >> b >> d >> e;

            for(int j = l; j - d >= 0; --j){
                add_edge(j, a - 1, j - d, b - 1, 0);
                add_edge(j, b - 1, j - d, a - 1, 0);
            }
            rep(j, l + 1){
                add_edge(j, b - 1, j, a - 1, e);
                add_edge(j, a - 1, j, b - 1, e);
            }
        }

        cout << dijkstra() << endl;
    }
    return 0;
}