#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

using Edge = tuple<ll, ll, ll>;
#include <queue>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m, s;
    cin, n, m, s;
    vector<vector<Edge>> g(n);
    REP(i, 0, m) {
        int u, v, a, b;
        cin, u, v, a, b;
        u--;
        v--;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }
    vector<ll> C(n), D(n);
    REP(i, 0, n) {
        cin, C[i], D[i];
    }
    ll Smax = 2510;
    chmin(s, Smax);

    priority_queue<Edge, vector<Edge>, greater<Edge>> pq;  // time, vertex, cost;
    pq.emplace(0, 0, s);
    const ll inf = 1LL << 60;
    auto Tm = make_v(n, Smax + 1, inf);
    Tm[0][s] = 0;
    while (pq.size()) {
        auto [tm, v, c] = pq.top();
        pq.pop();
        if (Tm[v][c] < tm) continue;
        Tm[v][c] = tm;

        {
            ll cc = c + C[v];
            chmin(cc, Smax);
            if (chmin(Tm[v][cc], Tm[v][c] + D[v])) {
                pq.emplace(Tm[v][c] + D[v], v, cc);
            }
        }
        for (auto [nto, aa, bb] : g[v]) {
            if (c >= aa && chmin(Tm[nto][c - aa], tm + bb)) {
                pq.emplace(tm + bb, nto, c - aa);
            }
        }
    }
    REP(i, 1, n) {
        ll ans = inf;
        REP(k, 0, Smax + 1) {
            chmin(ans, Tm[i][k]);
        }

        cout << ans << endl;
    }

    return 0;
}
