#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
struct edge { int u, v; ll w; };

void dijkstra(int n, vector<edge> G[], int s, ll d[]) {
	fill(d, d + n, LLONG_MAX); d[s] = 0;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > q;
	q.push(ll_i(0, s));
	while (!q.empty()) {
		ll_i p = q.top(); q.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				q.push(ll_i(d[e.v], e.v));
			}
		}
	}
}

vector<edge> G[100];
ll d[100];

int main() {
	for (;;) {
		int n, m, c, s, g;
		cin >> n >> m >> c >> s >> g;
		if (n == 0) break;
		vector< vector< vector<int> > > a(c, vector< vector<int> >(n, vector<int>(n)));
		for (int j = 0; j < c; j++)
			for (int u = 0; u < n; u++)
				for (int v = 0; v < n; v++)
					a[j][u][v] = (u == v ? 0 : INT_MAX / 2);
		for (; m > 0; m--) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--; c--;
			a[c][x][y] = min(a[c][x][y], d);
			a[c][y][x] = min(a[c][y][x], d);
		}
		for (int j = 0; j < c; j++)
			for (int k = 0; k < n; k++)
				for (int u = 0; u < n; u++)
					for (int v = 0; v < n; v++)
						a[j][u][v] = min(a[j][u][v], a[j][u][k] + a[j][k][v]);
		vector<int> p(c);
		for (int j = 0; j < c; j++) cin >> p[j];
		for (int u = 0; u < n; u++) G[u].clear();
		for (int j = 0; j < c; j++) {
			vector<int> q(p[j]), r(p[j]);
			for (int k = 1; k < p[j]; k++) cin >> q[k];
			for (int k = 0; k < p[j]; k++) cin >> r[k];
			vector<int> f(p[j]);
			for (int k = 1; k < p[j]; k++)
				f[k] = f[k - 1] + r[k - 1] * (q[k] - q[k - 1]);
			for (int u = 0; u < n; u++)
				for (int v = 0; v < n; v++) {
					int d = a[j][u][v];
					if (d == INT_MAX / 2) continue;
					int k = upper_bound(q.begin(), q.end(), d) - q.begin() - 1;
					int w = f[k] + r[k] * (d - q[k]);
					edge e = {u, v, w}; G[u].push_back(e);
				}
		}
		dijkstra(n, G, s - 1, d);
		cout << (d[g - 1] < LLONG_MAX ? d[g - 1] : -1) << endl;
	}
}