package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 4
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	s := getNextInt(scanner)
	ee := make([][]edge, n)
	cc := make([]int, n)
	dd := make([]int64, n)
	for i := 0; i < m; i++ {
		u := getNextInt(scanner) - 1
		v := getNextInt(scanner) - 1
		a := getNextInt(scanner)
		b := getNextInt64(scanner)
		appendEdge(u, v, i, a, b, ee)
		appendEdge(v, u, i, a, b, ee)
	}
	for i := 0; i < n; i++ {
		cc[i] = getNextInt(scanner)
		dd[i] = getNextInt64(scanner)
	}
	mx := 50*m + 1
	ans := makeInts(n, mx)
	d := &daikes{}
	heap.Init(d)
	for i := 0; i < n; i++ {
		for j := 0; j < mx; j++ {
			ans[i][j] = math.MaxInt64
		}
	}
	if s > mx-1 {
		s = mx - 1
	}
	heap.Push(d, daike{
		i: 0,
		a: s,
		b: 0,
	})
	for d.Len() > 0 {
		p := heap.Pop(d).(daike)

		if ans[p.i][p.a] < p.b {
			continue
		}
		ans[p.i][p.a] = p.b
		for a := p.a + cc[p.i]; a < mx; a += cc[p.i] {
			bb := p.b + int64((a-p.a)/cc[p.i])*dd[p.i]
			if ans[p.i][a] <= bb {
				break
			}
			ans[p.i][a] = bb
			heap.Push(d, daike{
				i: p.i,
				a: a,
				b: bb,
			})
		}
		for _, e := range ee[p.i] {
			if p.a-e.a < 0 {
				continue
			}
			if ans[e.to][p.a-e.a] <= p.b+e.b {
				continue
			}
			ans[e.to][p.a-e.a] = p.b + e.b
			heap.Push(d, daike{
				i: e.to,
				a: p.a - e.a,
				b: p.b + e.b,
			})
		}
	}

	for i := 1; i < n; i++ {
		q := ans[i][0]
		for j := 1; j < mx; j++ {
			if q > ans[i][j] {
				q = ans[i][j]
			}
		}
		fmt.Fprintln(writer, q)
	}
}

func appendEdge(from, to, id, a int, b int64, ee [][]edge) {
	ee[from] = append(ee[from], edge{
		to: to,
		id: id,
		a:  a,
		b:  b,
	})
}

type edge struct {
	to, id int
	a      int
	b      int64
}

func makeInts(h, w int) [][]int64 {
	index := make([][]int64, h, h)
	data := make([]int64, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type daike struct {
	i, a int
	b    int64
}

type daikes []daike

func (h daikes) Len() int           { return len(h) }
func (h daikes) Less(i, j int) bool { return h[i].b < h[j].b }
func (h daikes) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *daikes) Push(x interface{}) {
	*h = append(*h, x.(daike))
}
func (h *daikes) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 83796