#include using namespace std; using ll = long long; #define ALL(v) v.begin(),v.end() #define dbg(x) cerr << #x << ": " << (x) << endl; class Comb { int siz, mod; std::vector _fac, _inv, _finv; public: // 引数は (mod) Comb(int m) : mod(m), siz(2) { _fac.resize(siz); _inv.resize(siz); _finv.resize(siz); _fac[0] = _fac[1] = _inv[1] = _finv[0] = _finv[1] = 1; } long long p(int n, int k) { if (n < k || k < 0) return 0; resize(n + 1); return _fac[n] * _finv[n - k] % mod; } long long c(int n, int k) { if (n < k || k < 0) return 0; resize(n + 1); return _fac[n] * _finv[k] % mod * _finv[n - k] % mod; } long long inv(int n) { assert(n >= 0); resize(n + 1); return _inv[n]; } long long fac(int n) { assert(n >= 0); resize(n + 1); return _fac[n]; } long long finv(int n) { assert(n >= 0); resize(n + 1); return _finv[n]; } private: void resize(int n) { if (n <= siz) return; for (int i = siz; i < n; ++i) { _fac.push_back((long long)i * _fac[i - 1] % mod); _inv.push_back(mod - _inv[mod % i] * (mod / i) % mod); _finv.push_back(_finv[i - 1] * _inv[i] % mod); } siz = n; } }; int n,m,c; vector>> g; int inf = 1e9; int dijkstra(int C) { vector dp(n, -inf); priority_queue> pq; dp[0] = C; pq.emplace(C, 0); while (pq.size()) { auto [d, pos] = pq.top(); pq.pop(); if (dp[pos] > d) continue; for (auto&& [to,a,b] : g[pos]) { int cost = d / a + b; if (cost <= d && dp[to] < d - cost) { dp[to] = d - cost; pq.emplace(dp[to], to); } } } return dp[n-1]; } int main() { cin >> n >> m >> c; if (false) { Comb cb(1e9 + 7); ll ans = 0; for (int i = 0; i <= n; ++i) { dbg(cb.c(n, i)) ans += cb.p(n, i); } dbg(ans) } g.resize(n); for (int i = 0; i < m; ++i) { int a,b,c,d; cin >> a >> b >> c >> d; --a; --b; g[a].push_back({b,c,d}); g[b].push_back({a,c,d}); } for (int x = 1; x <= c; ++x) { int ans = dijkstra(x); if (ans == -inf) ans = -1; cout << ans << '\n'; } }