import java.util.*

fun main(args:Array<String>?): Unit {
    while(true){
        val (n, m, l) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0) return
        val town = Array(n){ Stack <Triple<Int, Int, Int>>()}
        val memo = Array(n){IntArray(l + 1){Int.MAX_VALUE}}
        repeat(m){
            val (a, b, d, e) = readLine()!!.trim().split(' ').map(String::toInt)
            town[a - 1].push(Triple(b - 1, d, e))
            town[b - 1].push(Triple(a - 1, d, e))
        }
        memo[0][l] = 0
        val queue = PriorityQueue<Triple<Int, Int, Int>>(compareBy(Triple<*, *, Int>::third))
        queue.add(Triple(0, l, 0))
        while(queue.isNotEmpty() && queue.peek().first != n - 1){
            val (current, money, enemy) = queue.poll()
            if (memo[current][money] == enemy){
                for ((to, distance, danger) in town[current]) {
                    if (money >= distance && memo[to][money - distance] > enemy) {
                        memo[to][money - distance] = enemy
                        queue.add(Triple(to, money - distance, enemy))
                    }
                    if (memo[to][money] > enemy + danger) {
                        memo[to][money] = enemy + danger
                        queue.add(Triple(to, money, enemy + danger))
                    }
                }
            }
        }
        println(memo.last().min())
    }
}
