namespace AtCoder; #nullable enable using System.Numerics; static class Extensions { public static T[] Repeat(this int time, Func F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } class AtCoder { object? Solve() { var n = Int(); var m = Int(); var cMax = Int(); var fz = new (int, int)[n, n]; for (var i = 0; i < m; i++) { var u = Int() - 1; var v = Int() - 1; var r = Int(); var w = Int(); fz[u, v] = fz[v, u] = (r, w); } var ans = new Stack(); for (var c = cMax; c > 0; c--) { var lz = n.Repeat(() => -1); lz[0] = c; var q = new PriorityQueue<(int v, int p), int>(); q.Enqueue((0, c), -c); while (q.Count > 0) { var (u, p) = q.Dequeue(); for (var v = 0; v < n; v++) { var (r, w) = fz[u, v]; if (r == 0) continue; var np = p - (p / r + w); if (np < 0 || lz[v] >= np) continue; lz[v] = np; q.Enqueue((v, np), -np); } } var lns = lz[n - 1]; ans.Push(lns); } Out(ans); return null; } public static void Main() => new AtCoder().Run(); public void Run() { var res = Solve(); if (res != null) { if (res is bool yes) res = yes ? "Yes" : "No"; sw.WriteLine(res); } sw.Flush(); } string[] input = Array.Empty(); int iter = 0; readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Trim().Split(' '), 0); return input[iter++]; } T Input() where T : IParsable => T.Parse(String(), null); int Int() => Input(); void Out(object? x, string? separator = null) { separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable obj and not string) { var firstLine = true; foreach (var item in obj) { if (!firstLine) sw.Write(separator); firstLine = false; sw.Write(item); } } else sw.Write(x); sw.WriteLine(); } }