#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 50;
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; }

struct edge{
    ll to;
    ll cost;
    edge(ll t, ll c){
        to = t;
        cost = c;
    }
};
//* dijkstra algorithm with adjacency list
void dijkstra(vector<vector<edge> > &G, vll &dist, ll s){
    fill(dist.begin(), dist.end(), INF);
    priority_queue<pll, vector<pll>, greater<pll> > que;
    dist[s] = 0;
    que.push(pll(0, s));
    while(!que.empty()){
        ll score = que.top().first;
        ll u = que.top().second;
        que.pop();
        for(ll i=0; i< G[u].size(); i++){
            edge e = G[u][i];
            if(dist[e.to] > score + e.cost){
                dist[e.to] = score + e.cost;
                que.push(pll(dist[e.to], e.to));
            }
        }
    }
    return;
}

ll W = 5051;
void solve(long long N, long long M, long long S, std::vector<long long> U, std::vector<long long> V, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, std::vector<long long> D){
    vector<vector<edge> > G(N * W);
    //* 1. intra-city
    for(ll i = 0; i < N; i++){//* city i
        for(ll k = 0; k +C[i] < W; k ++){
            G[i*W + k].push_back(edge(i*W + k + C[i], D[i]));
        }
    }
    //* 2. inter-city
    REP(m, M){
        ll u = U[m], v = V[m], money = A[m], cost = B[m];
        REP(k, W){ //* city u, with money k
            if(k >= money){
                G[u*W + k].push_back(edge(v*W+k - money, cost));
            }
        }
        REP(k, W){ //* city v, with money k
            if(k >= money){
                G[v*W+k].push_back(edge(u*W + k - money, cost));
            }
        }
    }
    //* decide start point
    vll dist(N*W, INF);
    if(S >= W) dijkstra(G, dist, W-1);
    else dijkstra(G, dist, S);

    for(ll t = 1; t < N; t++){
        ll ans = INF;
        REP(k, W){
            chmin(ans, dist[t*W + k]);
        }
        cout<<ans<<endl;
    }

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long S;
    scanf("%lld",&S);
    std::vector<long long> U(M);
    std::vector<long long> V(M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&U[i]);
        scanf("%lld",&V[i]);
        U[i]--; V[i]--;
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N);
    std::vector<long long> D(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&D[i]);
    }
    solve(N, M, S, std::move(U), std::move(V), std::move(A), std::move(B), std::move(C), std::move(D));
    return 0;
}


Measured memory_bytes: 44240