#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct edge {int to; ll cost; ll charge;};

int main()
{
  int n, m, s;
  cin >> n >> m >> s;
  s = min(s, 2500);
  vector<vector<edge>> g(n+1);
  rep(i, m) {
    int u, v;
    ll a, b;
    cin >> u >> v >> a >> b;
    edge x = {v, b, a};
    edge y = {u, b, a};
    g[u].push_back(x);
    g[v].push_back(y);
  }
  vector<ll> c(n+1), d(n+1);
  rep(i, n) cin >> c[i+1] >> d[i+1];

  priority_queue<pair<ll, pair<ll, int>>, vector<pair<ll, pair<ll, int>>>, greater<pair<ll, pair<ll, int>>>> pq;
  vector<vector<ll>> dist(n+1, vector<ll>(3000, INF64));
  dist[1][s] = 0;
  pq.push(make_pair(0ll, make_pair((ll)s, 1)));

  while(!pq.empty()) {
    auto p = pq.top(); pq.pop();
    ll len = p.first;
    ll sliver = p.second.first;
    int u = p.second.second;

    if(dist[u][sliver] < len) continue;

    //cout << u << " " << sliver << " " << len << endl

    if(sliver + c[u] <= 2500) {
      ll n_sliver = sliver+c[u];
      ll n_time = len + d[u];
      if(chmin(dist[u][n_sliver], n_time)) {
        pq.push(make_pair(n_time, make_pair(n_sliver, u)));
      }
    }

    for(auto next : g[u]) {
      int v = next.to;
      if(sliver < next.charge) continue;
      if(chmin(dist[v][sliver-next.charge], len+next.cost)) {
        pq.push(make_pair(dist[v][sliver-next.charge], make_pair(sliver-next.charge, v)));
      }
    }
  }

  for(int t = 2; t <= n; ++t) {
    ll res = INF64;
    for(int sl = 0; sl <= 2500; ++sl) {
      chmin(res, dist[t][sl]);
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 7516