#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef tuple<ll, ll, ll> tlll;
typedef pair<ll, ll> Pll;

ll N, M, S;
vector<vector<tlll>> graph;
vector<Pll> excha;

constexpr ll INF = 1e14;
constexpr ll MAXCOST = 2600;

int main() {
    cin >> N >> M >> S;
    graph.resize(N);
    for (int i = 0; i < M; i++) {
        ll U, V, A, B; cin >> U >> V >> A >> B;
        U--; V--;
        graph[U].push_back(tlll(V, A, B));
        graph[V].push_back(tlll(U, A, B));
    }
    excha.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> excha[i].first >> excha[i].second;
    }

    vector<vector<ll>> ans(N, vector<ll>(MAXCOST+1, INF));
    // time, node, money;
    priority_queue<tlll, vector<tlll>, greater<tlll>> pq;
    pq.push(tlll(0, 0, min(S, MAXCOST)));

    while (!pq.empty()) {
        ll t, n, m; tie(t, n, m) = pq.top(); pq.pop();
        if (ans[n][m] != INF) continue;

        ans[n][m] = t;
        ll nxt = m + excha[n].first;
        ll tt = t + excha[n].second;
        if (nxt <= MAXCOST) {
            if (ans[n][nxt] > tt) pq.push(tlll(tt, n, nxt));
        }
        for (auto x : graph[n]) {
            ll u, a, b; tie(u, a, b) = x;
            if (m >= a) {
                if (ans[u][m-a] > t+b) pq.push(tlll(t+b, u, m-a));
            }
        }
    }
    for (int i = 1; i < N; i++) {
        ll a = INF;
        for (int j = 0; j <= MAXCOST; j++) {
            a = min(a, ans[i][j]);
        }
        cout << a << endl;
    }
}
