#include "bits/stdc++.h"
using namespace std;
const int INF = 1 << 28;
int dist[20][100][100];
int d[100][100];
int p[20], q[20][50], r[20][50];
int main() {
	int n, m, c, s, g;
	while (cin >> n >> m >> c >> s >> g, n) {
		s--; g--;
		fill((int*)dist, (int*)(dist + 20), INF);
		for (int i = 0; i < c; i++) for (int j = 0; j < n; j++) dist[i][j][j] = 0;
		for (int i = 0; i < m; i++) {
			int x, y, d, num;
			cin >> x >> y >> d >> num;
			x--; y--;
			num--;
			dist[num][x][y] = dist[num][y][x] = min(dist[num][x][y], d);
		}
		for (int i = 0; i < c; i++) {
			scanf("%d", &p[i]);
		}
		for (int i = 0; i < c; i++) {
			for (int j = 0; j + 1 < p[i]; j++) {
				scanf("%d", &q[i][j]);
			}
			for (int j = 0; j< p[i]; j++) {
				scanf("%d", &r[i][j]);
			}
		}
		for (int com = 0; com < c; com++) {
			for (int k = 0; k < n; k++) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						dist[com][i][j] = min(dist[com][i][j], dist[com][i][k] + dist[com][k][j]);
					}
				}
			}
		}
		fill((int*)d, (int*)(d + n), INF);
		for (int i = 0; i < n; i++) d[i][i] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int tmp = INF;
				for (int com = 0; com < c; com++) {
					int cost = 0;
					if (dist[com][i][j] == INF) continue;
					if (p[com] == 1) {
						cost = dist[com][i][j] * r[com][0];
						tmp = min(tmp, cost);
						continue;
					}
					int prev = 0;
					for (int k = 0; k + 1 < p[com]; k++) {
						cost += (min(q[com][k], dist[com][i][j]) - prev)*r[com][k];
						prev = q[com][k];
						if (q[com][k] > dist[com][i][j]) break;
					}
					cost += max(dist[com][i][j] - q[com][p[com] - 2], 0)*r[com][p[com] - 1];
					tmp = min(tmp, cost);
				}
				d[i][j] = tmp;
			}
		}
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		if (d[s][g] == INF) cout << -1 << endl;
		else cout << d[s][g] << endl;
	}
}