#include<bits/stdc++.h>
using namespace std;

struct road
{
	int to, cost, k;//???????????????????????????
};
vector<road>rinsetu[100];
int mincost[100][101];//i??°??????j????????£?????????
struct A
{
	int x, y, z;//??´????????????????????????
};
bool operator <(A b, A c) {
	if (b.z != c.z)return b.z > c.z;
	return b.x * 1000 + b.y > c.x * 1000 + c.y;
}
signed main() {
	int a, b, c;
	while (scanf("%d%d%d", &a, &b, &c), a || b || c) {
		for (int d = 0; d < a; d++) {
			rinsetu[d].clear();
		}
		for (int d = 0; d < b; d++) {
			int e, f, g, h; scanf("%d%d%d%d", &e, &f, &g, &h);
			e--; f--;
			rinsetu[e].push_back({ f,g,h });
			rinsetu[f].push_back({ e,g,h });
		}
		memset(mincost, 0x3f, sizeof(mincost));
		mincost[0][c] = 0;
		priority_queue<A>Q;
		Q.push({0,c,0});
		while (Q.size()) {
			A d = Q.top(); Q.pop();
			if (d.z > mincost[d.x][d.y])continue;
			for (road i : rinsetu[d.x]) {
				//?????????????????????
				if (mincost[i.to][d.y] > d.z + i.k) {
					mincost[i.to][d.y] = d.z + i.k;
					Q.push({i.to,d.y,d.z + i.k });
				}
				//???????????????
				if (d.y >= i.cost) {
					if (mincost[i.to][d.y - i.cost] > d.z) {
						mincost[i.to][d.y - i.cost] = d.z;
						Q.push({ i.to, d.y - i.cost, d.z });
					}
				}
			}
		}
		int MIN = 1 << 29;
		for (int i = 0; i <= c; i++) {
			MIN = min(MIN, mincost[a-1][i]);
		}
		printf("%d\n", MIN);
	}
}