#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

struct edge {
    int to, cost, pay;
    edge(int to, int cost, int pay): pay(pay), to(to), cost(cost) {}
    edge() {
        edge(0,0,0);
    }
};

void Dijkstra(int s, vector<vector<edge>> g, VVLL &dp, VP &ex, VVLL &visited, int S) {
    int numv = dp.size();
    priority_queue<pair<LL,pair<int,int>>, vector<pair<LL,pair<int,int>>>, greater<pair<LL,pair<int,int>>>> q;
    dp[0][S] = 0;
    q.emplace(0,MP(0,S));

    while (!q.empty()) {
        pair<LL,pair<int,int>> p = q.top(); q.pop();
        LL d = p.first;
        int idx = p.second.first;
        int si = p.second.second;

        if (*min_element(dp[idx].begin() + si, dp[idx].end()) < d) continue;

        for (auto &e: g[idx]) {
            LL d = dp[idx][si];
            if (si-e.pay >= 0 && dp[e.to][si-e.pay] > d + e.cost) {
                dp[e.to][si-e.pay] = d + e.cost;
                //cerr << idx << ", " << e.to << endl;
                q.emplace(d + e.cost, MP(e.to, si-e.pay));
            }
        }
        if (si + ex[idx].first <= 10000) {
            if (dp[idx][si + ex[idx].first] > ex[idx].second + dp[idx][si]) {
                dp[idx][si + ex[idx].first] = ex[idx].second + dp[idx][si];
                q.emplace(dp[idx][si + ex[idx].first], MP(idx, si + ex[idx].first));
            }
        }
    }
}

void solve() {
    int n,m,s;
    cin >> n >> m >> s;
    vector<vector<edge>> es(n);
    VP ex(n);
    int u,v,a,b,c,d;
    REP(i,0,m) {
        cin >> u >> v >> a >> b;
        --u; --v;
        es[u].pb(v,b,a);
        es[v].pb(u,b,a);
    }
    REP(i,0,n) {
        cin >> c >> d;
        ex[i] = MP(c,d);
    }

    //dump("---");
    s = min(10000, s);
    VVLL dp(n, VLL(10000+1, 1LL<<60)), visited(n, VLL(10000+1));
    //dump("---");
    Dijkstra(0,es,dp,ex,visited,s);
    //dump("---");
    REP(i,1,n) {
        LL minv = 1LL << 60, index = -1;
        REP(j,0,10000+1) if (minv > dp[i][j]) {
            minv = dp[i][j];
            index = j;
        }
        cout << minv << endl;
        //dump(index);
    }

    return;
    REP(i,0,n) {
        REP(j,0,5) cerr << dp[i][j] << " ";
        cerr << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 11672