#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);
        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


 
void solve()
{     
    int n, m, s;
    cin>>n>>m>>s;

    const int max_cost = 50*100+100;
    s=min(s, max_cost-1);
    //need to make adjacenty
    vector<vector<pair<int, int> > > adj(n+1,vector<pair<int ,int> >(n+1) );
    for(int i=0;i<m;i++)
    {
        int u, v, a, b;
        cin>>u>>v>>a>>b;
        adj[u][v] = {a,b};
        adj[v][u] = {a,b};
    }

    vector<vector<int>> dp(n+1, vector<int>(max_cost, INF));


    vector<int> c(n+1), d(n+1);
    for(int i=1;i<=n;i++)
    {
        int cc, dd;
        cin>>cc>>dd;
        c[i]=cc;
        d[i]=dd;
    }
    //we will fix one per iteration
    dp[1][s]=0;

    for(int i=1;s+i*c[1]<max_cost;i++)
    {
        dp[1][s+i*c[1]]=i*d[1];
    }
    //brute over all others;

    for(int iter=0;iter<53;iter++)
    {
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<max_cost;j++)
            {
                for(int k=1;k<=n;k++)
                {
                    if(adj[i][k]!=make_pair((int)0,(int)0))
                    {
                        int new_min = dp[i][j];
                        //one possiblity is relaxation by lowers value
                        //the other is relaxation by edge 

                        //taking first case
                        int oler= j - c[i];
                        if(oler>=0)
                            dp[i][j]=min(dp[i][j], dp[i][oler]+d[i]);

                        //for second case move over all the related friends and try to find the minimum

                        int oller = j + adj[i][k].fi;
                        int timee = adj[i][k].se;
                        if(oller<max_cost)
                            dp[i][j] = min(dp[i][j], dp[k][oller]+ timee); 

                    }
                }
            }
        }
    }

    //now find the answer for all
    vector<int> ans(n+1, INF);
    for(int i=2;i<=n;i++)
    {
        for(int cost=0;cost<max_cost;cost++)
        {
            ans[i]=min(ans[i], dp[i][cost]);
        }
    }
    for(int i=2;i<=n;i++)
        cout<<ans[i]<<" ";
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 5360