//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 123;                                          
const int M = 3200;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
int a[N], b[N];
int e[N];
ll dp[N][M + 5];
int c[N], d[N]; 
vector < int > g[N];
ll ans[N];



int main () {
	SpeedForce;

	cin >> n >> m >> k;
	for (int i = 1; i <= m; ++i) {
		int v;
		cin >> v >> e[i] >> a[i] >> b[i];

		g[e[i]].pb(i);
		g[v].pb(i);

		e[i] ^= v;
	}

	For (i, 1, n) {
		ans[i] = INF;
		For (j, 0, M)
			dp[i][j] = INF;
	}

	For (i, 1, n) cin >> c[i] >> d[i];

	k = min(k, M);
	dp[1][k] = 0;
	set < pair < ll , pair<int,int> > > s;
	s.insert({0, {1, k}});

	while(s.size()) {
		int v = s.begin() -> S.F;
		int j = s.begin() -> S.S;
		ll now = s.begin() -> F;
		ans[v] = min(ans[v], now);
		s.erase(s.begin());
		{
			//~
			{
				int nxt = min(M, j+c[v]);
				if (dp[v][nxt] > now + d[v]) {
					s.erase({dp[v][nxt], {v, nxt}});
				
					dp[v][nxt] = now + d[v];
					s.insert({dp[v][nxt], {v, nxt}});
				}
			}
			//~
			
		   	for (auto it : g[v]) {
		   		int to = (v ^ e[it]);

				int need = (max(0, (a[it] - j)) + c[v] - 1) / c[v];
				int state = need * c[v] + j - a[it];
				ll cur = dp[v][j] + need * (ll)d[v] + b[it];

				state = min(state, M);
				if (dp[to][state] > cur) {
					s.erase({dp[to][state], {to, state}});


					dp[to][state] = cur;
					s.insert({dp[to][state], {to, state}});

				}
			}
		}
	}
		
	for (int i = 2; i <= n; ++i) {
		cout << ans[i] << '\n';
	/*	for (int j = 0; j <= M; ++j) if (dp[i][j] != INF) {
			ans = min(ans, dp[i][j]);
			for (auto e : g[i]) {
				int need = (max(0, (a[e] - j)) + c - 1) / c;
				int state = need * c + j - a[e];
				ll cur = dp[i][j] + need * (ll)d + b[e];
				state = min(state, M);

				dp[to[e]][state] = min(dp[to[e]][state], cur);
			}
		}*/

	//	cout << ans << '\n';
	}



	return Accepted;
}

// B...a

Measured memory_bytes: 9216