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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

template<typename T>
struct Edge {
	int from, to;
	T cost;
	Edge () {}
	Edge (int from, int to, T cost) : from(from), to(to), cost(cost) {}
	Edge (int to, T cost) : from(-1), to(to), cost(cost) {}
};

template<typename T>
vector<T> Dijkstra(int V, const vector<vector<Edge<T>>> &G, int s) {
	using Node = pair<T, int>;
	constexpr T INF = numeric_limits<T>::max();
	vector<T> d(V, INF);
	priority_queue<Node, vector<Node>, greater<Node>> pq;
	
	d[s] = 0;
	pq.emplace(0, s);
	while (!pq.empty()) {
		Node node = pq.top(); pq.pop();
		if (d[node.second] < node.first) continue;
		//cout << node.first << " " << node.second << endl;
		for (auto &e : G[node.second]) {
			T cost = e.cost + node.first;
			if (cost < d[e.to]) {
				d[e.to] = cost;
				pq.emplace(cost, e.to);
			}
		}
	}
	return (d);
}

int N, M, C, S, goal; 

int to_int(int c, int i) { return (c*N+i); }

bool solve() {
	cin >> N >> M >> C >> S >> goal;
	if (N == 0 && M == 0 && C == 0 && S == 0 && goal == 0) return (false);
	--S, --goal;
	vector<vector<vector<Edge<int>>>> ng(C, vector<vector<Edge<int>>>(N));
	vector<vector<Edge<int>>> G(N*C);
	vint P(C);
	for (int i = 0; i < M; i++) {
		int x, y, d, c; cin >> x >> y >> d >> c; --x, --y, --c;
		ng[c][x].emplace_back(y, d);		
		ng[c][y].emplace_back(x, d);
	}
	cin >> P;
	//cout << "A" << endl;
	for (int i = 0; i < C; i++) {
		vint q(P[i]);
		q[0] = 0;
		for (int j = 1; j < P[i]; j++) cin >> q[j];

		vint r(P[i]);   cin >> r;
		vint s(P[i], 0);
		for (int j = 0; j < P[i]-1; j++) {
			s[j+1] = s[j] + (q[j+1]-q[j]) * r[j];
		}
		
		for (int j = 0; j < N; j++) {
			vint dans = Dijkstra(N, ng[i], j);
			for (int k = 0; k < N; k++) {
				int distance = dans[k];
				if (distance == INT_MAX) continue;
				int pos = --upper_bound(begin(q), end(q), distance) - begin(q);
				int val = s[pos] + (distance - q[pos]) * r[pos];
				//cout << i << " " << j << " " << k << " " << pos << " " << distance << endl;
				//assert(val >= 0);
				G[to_int(i, j)].emplace_back(to_int(i, k), val);
			}
		}
		//cout << "B" << endl;
	}
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < N; k++) {
				G[to_int(i, k)].emplace_back(to_int(j, k), 0);
			}
		}
	}
	//cout << "C" << endl;
	vint ans = Dijkstra(N*C, G, S);
	//cout << "D" << endl;
	int minv = INF;
	for (int i = 0; i < C; i++) {
		chmin(minv, ans[to_int(i, goal)]);
	}
	cout << (minv == INF ? -1 : minv) << endl;
	return (true);
}	

void Main() {
	while (solve());
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}



Measured memory_bytes: 7128