#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 ull = unsigned 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 << 28;
const ll INF64 = 1ll << 55;
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; int money; ll time;};
int main()
{
  int n, m;
  ll s;
  cin >> n >> m >> s;
  s = min(s, 2500ll);
  vector<vector<edge>> g(n+1);

  rep(i, m) {
    int u, v, a;
    ll b;
    cin >> u >> v >> a >> b;
    edge x = {v, a, b};
    edge y = {u, a, b};
    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>> dp(n+1, vector<ll>(3000, INF64));

  priority_queue<tuple<ll, ll, int>, vector<tuple<ll, ll, int>>, greater<tuple<ll, ll, int>>> pq;
  dp[1][s] = 0;
  pq.push(make_tuple(0, s, 1));

  while(!pq.empty()) {
    auto p = pq.top(); pq.pop();
    ll time = get<0>(p), money = get<1>(p);
    int u = get<2>(p);

    if(dp[u][money] < time) continue;

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

    for(auto next : g[u]) {
      int v = next.to;
      if(money >= next.money) {
        if(chmin(dp[v][money-next.money], time+next.time)) {
          pq.push(make_tuple(dp[v][money-next.money], money-next.money, v));
        }
      }
    }
  }
  for(int t = 2; t <= n; ++t) {
    ll res = INF64;
    for(int money = 0; money <= 2500; ++money) chmin(res, dp[t][money]);
    cout << res << endl;
  }
}

Measured memory_bytes: 7608