#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)
#define exist(c, v) (find((c).begin(), (c).end(), (v)) != (c).end())

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

const int INF = 0xfffffff;
int n, m, c, s, g;
vector<vector<int> > cost;
typedef pair<int, int> P;


int dijkstra(int s, int g) {
	vector<int> dist(n, INF);
	dist[s] = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, s));

	while(!que.empty()) {
		const int v = que.top().second, d = que.top().first;
		que.pop();
		if(d > dist[v])
			continue;

		if(v == g)
			return d;

		for(int i = 0; i < n; ++i) {
			if(cost[v][i] >= INF)
				continue;

			const int next_d = d + cost[v][i];
			if(next_d < dist[i]) {
				dist[i] = next_d;
				que.push(P(next_d, i));
			}
		}
	}

	return -1;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(cin >> n >> m >> c >> s >> g, n) {
		--s;
		--g;
		int mat[c][n][n];
		fill(mat[0][0], mat[0][0] + c * n * n, INF);
		for(int j = 0; j < c; ++j)
			for(int i = 0; i < n; ++i)
				mat[j][i][i] = 0;

		for(int i = 0; i < m; ++i) {
			int x, y, d, cc;
			cin >> x >> y >> d >> cc;
			--x;
			--y;
			--cc;
			mat[cc][x][y] = mat[cc][y][x] = min(mat[cc][y][x], d);
		}

		for(int l = 0; l < c; ++l)
			for(int k = 0; k < n; ++k)
				for(int i = 0; i < n; ++i)
					for(int j = 0; j < n; ++j)
						chmin(mat[l][i][j], mat[l][i][k] + mat[l][k][j]);

		vector<int> p(c);
		for(int i = 0; i < c; ++i)
			cin >> p[i];

		cost.clear();
		cost.resize(n, vector<int>(n, INF));
		for(int i = 0; i < n; ++i)
			cost[i][i] = 0;

		for(int i = 0; i < c; ++i) {
			vector<int> q(p[i] + 1, INF);
			q[0] = 0;
			for(int j = 1; j < p[i]; ++j)
				cin >> q[j];

			vector<int> r(p[i]);
			for(int j = 0; j < p[i]; ++j)
				cin >> r[j];
			
			for(int j = 0; j < n; ++j) {
				for(int k = 0; k < n; ++k) {
					if(mat[i][j][k] >= INF)
						continue;

					int tmp = 0;
					for(int l = 1; l <= p[i]; ++l) {
						if(mat[i][j][k] <= q[l]) {
							tmp += (mat[i][j][k] - q[l - 1]) * r[l - 1];
							cost[j][k] = cost[k][j] = min(cost[k][j], tmp);
							break;
						}
						else {
							tmp += (q[l] - q[l - 1]) * r[l - 1];
						}
					}
				}
			}
		}
		cout << dijkstra(s, g) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2152