#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<T,int>>> & G){
    const T inf=numeric_limits<T>::max();
    using edge=pair<T,int>;
    priority_queue<edge, vector<edge>, greater<edge> > que;
    int n=G.size();
    vector<T> d(n,inf);
    vector<int> b(n,-1);
    d[s]=0;
    que.emplace(d[s],s);
    while (!que.empty()){
        edge p = que.top(); que.pop();
        int v = p.second;
        if (d[v]<p.first) continue;
        for(auto& e:G[v]){
            int u=e.second;
            T c=e.first;
            if (d[u]>d[v]+c){
                d[u]=d[v]+c;
                b[u]=v;
                que.emplace(d[u],u);
            }
        }
    }
    return d;
}

int n,m,S,max_c=0;
int u[155],v[155],a[155],b[155],c[55],d[55];
vector<vector<pair<ll,int>>> G;

void solve(){
    cin >> n >> m >> S;
    rep(i,m){
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--;v[i]--;
        max_c+=a[i];
    }
    rep(i,n){
        cin >> c[i] >> d[i];
    }
    max_c+=1;
    G.resize(n*max_c);
    rep(i,m){
        rep(t,max_c){
            if(t>=a[i]){
                G[u[i]*max_c+t].emplace_back(b[i],v[i]*max_c+t-a[i]);
                G[v[i]*max_c+t].emplace_back(b[i],u[i]*max_c+t-a[i]);
            }
        }
    }
    //cout << G.size() << endl;
    rep(i,n){
        rep(t,max_c){
            G[i*max_c+t].emplace_back(d[i],i*max_c+min(max_c-1,t+c[i]));
        }
    }
    vector<ll> D=dijkstra(0+min(max_c-1,S),G);
    //cout << D.size() << endl;
    Rep(t,1,n){
        ll ans=INF;
        rep(j,max_c){
            ans=min(ans,D[t*max_c+j]);
        }
        cout << ans << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}