// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
struct Edge{ll to,cost;};
vector<vector<Edge>> G(50*2510);
ll etime[50*2510];
ll ex_cost[50];
ll ex_time[50];
ll INF=(1000*1000*1000ll) *(1000*1000*1000ll);
ll R=2510;
int main() {
    cout.precision(10);
    cout<<fixed;
    ll N,M,S;
    cin>>N>>M>>S;
    S=min(S,2500ll);
    REP(i,50*2510)
        etime[i]=INF;
    REP(cnt,M) {
        ll U,V,A,B;
        cin>>U>>V>>A>>B;--U;--V;
        for(ll i=2500;i-A>=0;--i) {
            G[U*R+i].pb({V*R+i-A,B});
        }
        for(ll i=2500;i-A>=0;--i) {
            G[V*R+i].pb({U*R+i-A,B});
        }
    }
    REP(i,N) {
        ll c,t;
        cin >>c>>t;
        for(int j=0;j<=2500;++j) {
            G[i*R+j].pb({i*R+min(j+c,2500ll),t});
        }
    }

    priority_queue<P,vector<P>,greater<P>> Q;
    Q.push({0,S});
    etime[S]=0;
    while(!Q.empty()) {
        auto p=Q.top();
        Q.pop();
        if (p.fi>etime[p.se])continue;
        etime[p.se]=p.fi;
        for(auto e:G[p.se]) {
            ll n=e.cost+etime[p.se];
            if (etime[e.to]>n) {
                etime[e.to]=n;
                Q.push({n,e.to});
            }
        }
    }
    for(int i=1;i<N;++i) {
        ll ans=INF;
        REP(j,2510)
            ans=min(ans,etime[i*2510+j]);
        cout<<ans<<endl;
    }
}

struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};


Measured memory_bytes: 23768