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

using ll = long long;
#define int ll

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmax(a, b) a = max(a, (b))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

#ifdef LOCAL_DEBUG_OPTION
namespace debug_print_n{
struct DebugPrint {
	template<class T, class U = remove_const_t<remove_reference_t<T>>>
	static enable_if_t<is_integral<U>::value && !is_same<U, bool>::value && !is_same<U, char>::value> DUMP_SUB_FUNCTION(T x) {
		cerr << x;
	}
	template<class T, class U = remove_const_t<remove_reference_t<T>>>
	static enable_if_t<is_same<U, bool>::value> DUMP_SUB_FUNCTION(T x) {
		if (x) cerr << "True";
		else cerr << "False";
	}
	template<class T, class U = remove_const_t<remove_reference_t<T>>>
	static enable_if_t<is_same<U, char>::value> DUMP_SUB_FUNCTION(T x) {
		cerr << '\'' << x << '\'';
	}
	template<class T, class U = remove_const_t<remove_reference_t<T>>>
	static enable_if_t<is_same<U, string>::value> DUMP_SUB_FUNCTION(T x) {
		cerr << '\"' << x << '\"';
	}
	template<class T>
	static enable_if_t<is_same<T, const char*>::value> DUMP_SUB_FUNCTION(T x) {
		cerr << string(x);
	}
	template<class T>
	static enable_if_t<true> DUMP_SUB_FUNCTION(vector<T> x) {
		cerr << '{';
		for (size_t i = 0; i < x.size(); i++) {
			if (i) cerr << ", ";
			DUMP_SUB_FUNCTION(x[i]);
		}
		cerr << '}';
	}
	template<class T, size_t N>
	static enable_if_t<true> DUMP_SUB_FUNCTION(array<T, N> x) {
		cerr << '{';
		for (size_t i = 0; i < x.size(); i++) {
			if (i) cerr << ", ";
			DUMP_SUB_FUNCTION(x[i]);
		}
		cerr << '}';
	}
	template<class T>
	static enable_if_t<true> DUMP_SUB_FUNCTION(set<T> x) {
		cerr << '[';
		size_t i = 0;
		for (auto itr = x.begin(); itr != x.end(); itr++, i++) {
			if (i) cerr << ", ";
			DUMP_SUB_FUNCTION(*itr);
		}
		cerr << ']';
	}
	template<class T, class U>
	static enable_if_t<true> DUMP_SUB_FUNCTION(map<T, U> x) {
		cerr << '[';
		size_t i = 0;
		for (auto itr = x.begin(); itr != x.end(); itr++, i++) {
			if (i) cerr << ", ";
			DUMP_SUB_FUNCTION(itr->first);
			cerr << " : ";
			DUMP_SUB_FUNCTION(itr->second);
		}
		cerr << ']';
	}
	template<class T, class U = remove_const_t<remove_reference_t<T>>>
	static enable_if_t<is_floating_point<U>::value> DUMP_SUB_FUNCTION(T x) {
		cerr << fixed << setprecision(5) << x;
	}
	template<class T, class U>
	static enable_if_t<true> DUMP_SUB_FUNCTION(pair<T, U> p) {
		cerr << '(';
		DUMP_SUB_FUNCTION(p.first);
		cerr << ", ";
		DUMP_SUB_FUNCTION(p.second);
		cerr << ')';
	}
	template<int num = 0, class... Args>
	static enable_if_t<num == sizeof...(Args)> DUMP_SUB_FUNCTION(tuple<Args...> t) {
		if (num) cerr << ')';
	}
	template<int num = 0, class... Args>
	static enable_if_t<num < sizeof...(Args)> DUMP_SUB_FUNCTION(tuple<Args...> t) {
		if (num == 0) cerr << '(';
		DUMP_SUB_FUNCTION(get<num>(t));
		if (num + 1 < sizeof...(Args)) cerr << ", ";
		DUMP_SUB_FUNCTION<num+1>(t);
	}
	template<long unsigned N>
	static enable_if_t<true> DUMP_SUB_FUNCTION(bitset<N> x) {
		cerr << x;
	}
};
void dump() {
	cerr << endl;
}
template<class Head, class... Tail>
void dump(Head&& head, Tail&&... tail) {
	DebugPrint::DUMP_SUB_FUNCTION(head);
	if (sizeof...(Tail) != 0) {
		cerr << ' ';
	}
	dump(forward<Tail>(tail)...);
}
} // namespace debug_print_n
using debug_print_n::dump;
#else
template<class... Args> void dump(Args&&... args) { }
#endif

namespace bit {
using u32 = uint_fast32_t;
using u64 = unsigned long long;
template<class T>
constexpr T set(T bin, u32 pos) {
	return bin | (1ull << pos);
}
template<class T>
constexpr T unset(T bin, u32 pos) {
	return bin & ~(1ull << pos);
}
template<class T>
constexpr T get(T bin, u32 pos) {
	return bin & (1ull << pos);
}
template<class T>
constexpr bool check(T bin, u32 pos) {
	return get(bin, pos);
}
constexpr u32 popcount(u64 bin) {
	return __builtin_popcountll(bin);
}
} // namespace bit

namespace dijkstra_n {
using u32 = uint_fast32_t;
template <class T>
class has_shortest_path_graph_tag {
	template <class U> static constexpr std::true_type check(typename U::shortest_path_graph_tag*);
	template <class U> static constexpr std::false_type check(...);
public:
	static constexpr bool value = decltype(check<T>(nullptr))::value;
};
template <class T> constexpr bool has_shortest_path_graph_tag_v = has_shortest_path_graph_tag<T>::value;
template<class Graph, class WEIGHT = typename Graph::WEIGHT_TYPE>
enable_if_t<has_shortest_path_graph_tag_v<Graph>> Dijkstra(Graph& G, u32 start, WEIGHT INF_COST) {
	auto& e = G.e;
	for (u32 i = 0; i < G.size(); i++) {
		G.dist(i) = INF_COST;
		G.valid(i) = false;
	}
	using Q_T = pair<WEIGHT, int>;
	priority_queue<Q_T, vector<Q_T>, greater<>> q;
	q.emplace(WEIGHT(0), start);
	while (!q.empty()) {
		auto a = q.top(); q.pop();
		G.valid(a.second) = 1;
		if (a.first >= G.dist(a.second)) continue;
		G.dist(a.second) = a.first;
		for (auto& x : e[a.second]) {
			if (x.weight == INF_COST) continue;
			if (a.first + x.weight < G.dist(x.to)) q.emplace(a.first + x.weight, x.to);
		}
	}
}
}
using dijkstra_n::Dijkstra;

namespace shortest_path_graph_n {
template<class EDGE, class VERTEX>
struct Graph {
	using u32 = uint_fast32_t;
	using i32 = int_fast32_t;
	using u64 = uint_fast64_t;
	struct graph_tag {};
	const u32 n;
	vector<vector<EDGE>> e;
	vector<VERTEX> v;
	vector<u64> idx;
	Graph(u32 N) : n(N), e(n), v(n) {}
	template<class...  Args> void add_edge(u32 from, u32 to, Args... args) {
		idx.push_back((static_cast<u64>(from) << 32) | e[from].size());
		e[from].emplace_back(to, args...);
	}
	u32 size() const {return n;}
	using EDGE_TYPE = EDGE;
	using VERTEX_TYPE = VERTEX;
};
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
template<class WEIGHT>
struct Vertex {
	WEIGHT dist;
	bool valid;
};
template<class WEIGHT>
struct Edge {
	u32 to;
	WEIGHT weight;
	Edge(u32 x, WEIGHT w) : to(x), weight(w) {}
};
template<class WEIGHT>
struct ShortestPathGraph : Graph<Edge<WEIGHT>, Vertex<WEIGHT>> {
	struct shortest_path_graph_tag {};
	ShortestPathGraph(u32 N) : Graph<Edge<WEIGHT>, Vertex<WEIGHT>>(N) {}
	WEIGHT& dist(u32 i) {return this->v[i].dist;}
	bool& valid(u32 i) {return this->v[i].valid;}
	using WEIGHT_TYPE = WEIGHT;
};
template<class WEIGHT = long long>
ShortestPathGraph<WEIGHT> make_shortest_path_graph(u32 N) {
	return move(ShortestPathGraph<WEIGHT>(N));
}
} // shortest_path_graph_n
using shortest_path_graph_n::ShortestPathGraph;
using shortest_path_graph_n::make_shortest_path_graph;

constexpr int SMAX = 50 * 50 * 2 + 10;
constexpr int INF = 1e16;

signed main(){
	int N, M, S; cin >> N >> M >> S;
	auto G = make_shortest_path_graph(N * SMAX);
	auto z = [&](int n, int s) {
		return SMAX * n + s;
	};
	rep(i, M) {
		int U, V, A, B; cin >> U >> V >> A >> B; U--, V--;
		reps(j, A, SMAX) {
			G.add_edge(z(U, j), z(V, j-A), B);
			G.add_edge(z(V, j), z(U, j-A), B);
		}
	}
	rep(i, N) {
		int C, D; cin >> C >> D;
		rep(j, SMAX) {
			G.add_edge(z(i, j), z(i, min(j+C, SMAX-1)), D);
		}
	}
	Dijkstra(G, z(0, min(S, SMAX-1)), INF);
	vector<int> res(N, INF);
	reps(i, 0, N) {
		rep(j, SMAX) {
			chmin(res[i], G.dist(z(i, j)));
			// if (G.dist(z(i, j)) == INT_MAX) cerr << "x ";
			// else cerr << G.dist(z(i, j)) << ' ';
		}
		// cerr << endl;
	}
	reps(i, 1, N) cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 65000