#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 time; ll money;};

int main()
{
  int n, m;
  ll s;
  cin >> n >> m >> s;
  s = min(2500ll, s);
  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];

  vector<vector<ll>> dist(n+1, vector<ll>(3000, INF64));
  priority_queue<tuple<ll, ll, int>, vector<tuple<ll, ll, int>>, greater<tuple<ll, ll, int>>> pq;

  dist[1][s] = 0;
  pq.push(make_tuple(0ll, s, 1));
  while(!pq.empty()) {
    auto p = pq.top(); pq.pop();
    ll time = get<0>(p);
    ll money = get<1>(p);
    int u = get<2>(p);
    if(dist[u][money] < time) continue;

    if(money + c[u] <= 2500) {
      if(chmin(dist[u][money+c[u]], dist[u][money]+d[u])) {
        pq.push(make_tuple(dist[u][money+c[u]], money+c[u], u));
      }
    }

    for(auto next : g[u]) {
      int v = next.to;
      if(money >= next.money && chmin(dist[v][money-next.money], dist[u][money]+next.time)) {
        pq.push(make_tuple(dist[v][money-next.money], money-next.money, 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: 7536