using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC164E_2
{
    class Program
    {
        static void Main(string[] args)
        {
            long INF = long.MaxValue / 2;

            var N = RInt;
            var M = RInt;
            var S = RLong;

            List<Edge>[] edges = new List<Edge>[N].Select(x => new List<Edge>()).ToArray();
            for (int i = 0; i < M; i++)
            {
                var u = RInt - 1;
                var v = RInt - 1;
                var a = RInt;
                var b = RInt;
                edges[u].Add(new Edge() { to = v, cost = a, time = b });
                edges[v].Add(new Edge() { to = u, cost = a, time = b });
            }

            int[] C = new int[N];
            int[] D = new int[N];
            for (int i = 0; i < N; i++)
            {
                C[i] = RInt;
                D[i] = RInt;
            }

            long[,] minTime = new long[N, 50 * N];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < 50 * N; j++)
                {
                    minTime[i, j] = INF;
                }
            }
            if (S >= 50 * N) S = 50 * N - 1;
            minTime[0, S] = 0;

            PriorityQueue<State> que = new PriorityQueue<State>();
            que.Enqueue(new State() { now = 0, cost = S, time = 0 });
            while (que.Count() > 0)
            {
                var from = que.Dequeue();

                foreach (var e in edges[from.now])
                {

                    long c1 = from.cost - e.cost;
                    long t1 = minTime[from.now, from.cost] + e.time;
                    if (c1 >= 0 && minTime[e.to, c1] > t1)
                    {
                        minTime[e.to, c1] = t1;
                        que.Enqueue(new State() { now = e.to, cost = c1, time = t1 });
                    }

                    long c2 = from.cost + C[from.now];
                    long t2 = minTime[from.now, from.cost] + D[from.now];
                    if (c2 < 50 * N && c2 >= 0 && minTime[from.now, c2] > t2)
                    {
                        minTime[from.now, c2] = t2;
                        que.Enqueue(new State() { now = from.now, cost = c2, time = t2 });
                    }
                }
            }

            //Draw2D(minTime);

            for (int i = 1; i < N; i++)
            {
                long ans = INF;
                for (int j = 0; j < 50 * N; j++)
                {
                    ans = Math.Min(ans, minTime[i, j]);
                }
                Console.WriteLine(ans);
            }
        }

        public struct State : IComparable<State>
        {
            public int now;
            public long cost;
            public long time;

            public int CompareTo(State other)
            {
                return cost.CompareTo(other.cost);
            }
        }

        public struct Edge
        {
            public int to;
            public long cost;
            public long time;
        }
    }

    public class PriorityQueue<T> where T : IComparable<T>
    {
        private IComparer<T> _comparer = null;
        private int _type = 0;

        private T[] _heap;
        private int _sz = 0;

        private int _count = 0;

        /// <summary>
        /// Priority Queue with custom comparer
        /// </summary>
        public PriorityQueue(IComparer<T> comparer)
        {
            _heap = new T[128];
            _comparer = comparer;
        }

        /// <summary>
        /// Priority queue
        /// </summary>
        /// <param name="type">0: asc, 1:desc</param>
        public PriorityQueue(int type = 0)
        {
            _heap = new T[128];
            _type = type;
        }

        private int Compare(T x, T y)
        {
            if (_comparer != null) return _comparer.Compare(x, y);
            return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
        }

        public void Enqueue(T x)
        {
            _count++;
            if (_count > _heap.Length)
            {
                var newheap = new T[_heap.Length * 2];
                for (int n = 0; n < _heap.Length; n++) newheap[n] = _heap[n];
                _heap = newheap;
            }

            //node number
            var i = _sz++;

            while (i > 0)
            {
                //parent node number
                var p = (i - 1) / 2;

                if (Compare(_heap[p], x) <= 0) break;

                _heap[i] = _heap[p];
                i = p;
            }

            _heap[i] = x;
        }

        public T Dequeue()
        {
            _count--;

            T ret = _heap[0];
            T x = _heap[--_sz];

            int i = 0;
            while (i * 2 + 1 < _sz)
            {
                //children
                int a = i * 2 + 1;
                int b = i * 2 + 2;

                if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b;

                if (Compare(_heap[a], x) >= 0) break;

                _heap[i] = _heap[a];
                i = a;
            }

            _heap[i] = x;

            return ret;
        }

        public int Count()
        {
            return _count;
        }

        public T Peek()
        {
            return _heap[0];
        }

        public bool Contains(T x)
        {
            for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true;
            return false;
        }

        public void Clear()
        {
            while (this.Count() > 0) this.Dequeue();
        }

        public IEnumerator<T> GetEnumerator()
        {
            var ret = new List<T>();

            while (this.Count() > 0)
            {
                ret.Add(this.Dequeue());
            }

            foreach (var r in ret)
            {
                this.Enqueue(r);
                yield return r;
            }
        }

        public T[] ToArray()
        {
            T[] array = new T[_sz];
            int i = 0;

            foreach (var r in this)
            {
                array[i++] = r;
            }

            return array;
        }
    }
}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(long[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            long[,] map2 = new long[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 30332