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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
struct Vertex {
	// edge information
	vector<int> edges_to; //to vertex number
	vector<ll> edges_cost; // edge cost
	
	//for dijkstra
	bool done; //conform or not
	ll cost; // now cost
	int from;
	
	bool operator<(const Vertex& another) const { // priority --> min
        return another.cost < cost; // order(cost)
    }
	
	bool operator==(const Vertex& another) const {
        return another.cost == cost; // order(cost)
    }
};

int W = 2501;
int H = 50;

int to1(int i, int j){ // i < H, j < W
	return i*W + j;
}

pair<int,int> to2(int num){
	return MP(num / W, num % W);
}

const int VMAX = 50*2501;
int main() {
	vector<Vertex> Ver(VMAX);
	int N,M,S;
	cin >> N >> M >> S;
	chmin(S,2500); // S --- > 2500

	REP(i,M){
		ll U,V,A,B;
		cin >> U >> V >> A >> B;
		U--; V--;
		REP(w,W){
			if (w - A < 0) continue;
			Ver[to1(U,w)].edges_to.push_back(to1(V,w-A));
			Ver[to1(U,w)].edges_cost.push_back(B);

			Ver[to1(V,w)].edges_to.push_back(to1(U,w-A));
			Ver[to1(V,w)].edges_cost.push_back(B);
		}
	}

	REP(i,N){
		ll C,D; cin >> C >> D;
		REP(w,W){
			ll nextw = min(2500LL,w + C);
			Ver[to1(i,w)].edges_to.push_back(to1(i,nextw));
			Ver[to1(i,w)].edges_cost.push_back(D);
		}
	}

	REP(i,VMAX){
		Ver[i].done = false;
		Ver[i].cost = -1;
	}
	
	priority_queue<Vertex> Q;
	Ver[to1(0,S)].cost = 0; //start
	Q.push(Ver[to1(0,S)]);
	
	while (!Q.empty()){
		Vertex nowV = Q.top(); Q.pop();
		nowV.done = true;
		
		REP(i,nowV.edges_to.size()){
			int nto = nowV.edges_to[i];
			ll ncost = nowV.cost + nowV.edges_cost[i];
			if (((Ver[nto].cost) < 0) or (ncost < Ver[nto].cost)){  //not visited or required refresh
				Ver[nto].cost = ncost;
				Q.push(Ver[nto]);
			
			}
		}
	}
	
	ll ans = 1e15;
	for (size_t t = 1; t < N; t++) {
		ll nans = 1e15;
		REP(w,W){
			if (Ver[to1(t,w)].cost < 0) continue;
			chmin(nans,Ver[to1(t,w)].cost);
		}
		cout << nans << "\n";
	}
}

Measured memory_bytes: 40668