#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
#define INF 1LL<<40

int N, M, C, S, G;
ll d[20][100][100];
int P[20];
int Q[20][50];
int R[20][50];

ll dd[100][100];

ll getCost(int c, ll dist)
{
	if (P[c] == 1) return dist * R[c][0];
	if (dist <= Q[c][0]) return dist * R[c][0];

	ll ret = 0;

	int i = 0;
	while (Q[c][i] < dist)
	{
		if (i == 0)
			ret += Q[c][0] * R[c][0];
		else
			ret += (Q[c][i] - Q[c][i - 1]) * R[c][i];

		i++;
		if (i == P[c] - 1)
		{
			ret += (dist - Q[c][i-1]) * R[c][i];
			return ret;
		}
	}

	ret += (dist - Q[c][i - 1]) * R[c][i];
	return ret;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (cin >> N >> M >> C >> S >> G)
	{
		if (N == 0) return 0;
		S--; G--;

		rep(i, 0, C) rep(j, 0, N) rep(k, 0, N) d[i][j][k] = INF;
		rep(i, 0, C) rep(j, 0, N) d[i][j][j] = 0;
		rep(i, 0, N) rep(j, 0, N) dd[i][j] = INF;
		rep(i, 0, N) dd[i][i] = 0;
		
		rep(i, 0, M)
		{
			int x, y, c; 
			ll _d;
			cin >> x >> y >> _d >> c;
			x--; y--; c--;

			d[c][x][y] = min(d[c][x][y], _d);
			d[c][y][x] = min(d[c][y][x], _d);
		}

		rep(_i, 0, C) rep(k, 0, N) rep(i, 0, N) rep(j, 0, N)
			d[_i][i][j] = min(d[_i][i][j], d[_i][i][k] + d[_i][k][j]);

		rep(i, 0, C) cin >> P[i];
		rep(i, 0, C)
		{
			rep(j, 0, P[i] - 1) cin >> Q[i][j];
			rep(j, 0, P[i]) cin >> R[i][j];
		}

		rep(i, 0, N) rep(j, 0, N) rep(k, 0, C) if(d[k][i][j] != INF) if(i != j)
		{
			ll cost = getCost(k, d[k][i][j]);

			dd[i][j] = min(dd[i][j], cost);

			//printf("[%d %d %d] -> %lld -> %lld\n", k, i, j, d[k][i][j], cost);
		}

		rep(k, 0, N) rep(i, 0, N) rep(j, 0, N)
			dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j]);

		if (dd[S][G] == INF)
			cout << -1 << endl;
		else
			cout << dd[S][G] << endl;
	}
}