#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

struct Edge{
    int to,mai,t;
    Edge(){}
    Edge(int to,int mai,int t){
        this->to = to;
        this->mai = mai;
        this->t = t;
    }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef tuple<ll,ll,ll> T;
const ll INF = 1e+15;
ll dp[50][2501];
ll c[50],d[50];
int main(){
    int n,m,s;
    cin>>n>>m>>s;

    Graph g(n);
    rep(i,m){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        u--;v--;
        g[u].push_back(Edge(v,a,b));
        g[v].push_back(Edge(u,a,b));
    }
    rep(i,n) cin>>c[i]>>d[i];


    rep(i,n) rep(j,2501) dp[i][j]=INF;

    s = min(s,2500);
    priority_queue<T,vector<T>,greater<T>> que;
    que.push(T(0,0,s));

    while(!que.empty()){
        T now = que.top();que.pop();

        ll t = get<0>(now);
        ll pos =get<1>(now);
        ll mai = get<2>(now);
        if(dp[pos][mai]<=t) continue;
        dp[pos][mai]=t;
        rep(i,g[pos].size()){
            Edge e = g[pos][i];
            if(mai>=e.mai){
                que.push(T(t+e.t,e.to,mai-e.mai));
            } 
        }
        que.push(T(t+d[pos],pos,min((ll)2500,mai+c[pos])));
    }
    
    for(int i = 1;i<n;i++){
        ll ans = INF;
        rep(j,2501){
            ans = min(ans,dp[i][j]);
        }
        cout<<ans<<endl;
    }
    return 0;

}