#include <bits/stdc++.h>

using namespace std;

struct Edge{
	int v, a, b;
};

const int MAX = 2500;
int n, m, s;
int c[51], d[51];
long long dist[51][2510];
vector<Edge> adj[51];
priority_queue<pair<long long, pair<int, int> > > pq;
bool vis[51][2510];

void Dijkstra(){
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= MAX; j++)
			dist[i][j] = 1e18;

	dist[1][min(MAX, s)] = 0;
	pq.push({0, {1, min(MAX, s)}});

	int cnt = 0;
	while(!pq.empty()){
		long long dis; int t, u;

		dis = -pq.top().first; tie(u, t) = pq.top().second; pq.pop();

		if(vis[u][t]) continue;

		vis[u][t] = true;

		for(auto &k : adj[u]){
			if(t - k.a >= 0 && dist[k.v][t - k.a] > dis + k.b){
				++cnt;
				dist[k.v][t - k.a] = dis + k.b;
				pq.push({-dist[k.v][t - k.a], {k.v, t - k.a}});
			}
		}

		long long tp = 0;
		while(true){
			t += c[u];
			tp += d[u];

			if(dist[u][min(MAX, t)] > dis + tp){
				dist[u][min(MAX, t)] = dis + tp;
				pq.push({-(dis + tp), {u, min(MAX, t)}});
			} else break;

			if(t > MAX) break;
		}
	}

	// cout << cnt << "\n";
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	cin >> n >> m >> s;

	while(m--){
		int u, v, a, b;

		cin >> u >> v >> a >> b;

		adj[u].emplace_back(Edge({v, a, b}));
		adj[v].emplace_back(Edge({u, a, b}));
	}

	for(int i = 1; i <= n; i++) cin >> c[i] >> d[i];

	Dijkstra();

	for(int i = 2; i <= n; i++){
		long long ans = 1e18;
		for(int sil = 0; sil <= MAX; sil++){
			ans = min(ans, dist[i][sil]);
		}

		cout << ans << "\n";
	}
	
	return 0;
}