#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n,m,c,s,g;
const int INF =  1e9+9;

int dist[25][105][105];
int val[105][105];
int p[25];
int dtov[25][20005];

int dij(int ss, int gg){
	bool done[105];
	int d[105];
	for(int i=0;i<n;i++)
		d[i] = INF;

	for(int i=0;i<n;i++)
			done[i] = false;
	d[ss] = 0;
	int minv = INF;
	//cout << "ダイクストラ" << endl;
	while(1){
		minv = INF;
		int u = -1;
		for(int i=0;i<n;i++)
		{
			if(done[i] == false and minv > d[i])
			{
				u = i;
				minv = d[i];
			}
		}
		if(u == -1) break;
		done[u] = true;
		//cout << u << "= " << d[u] << endl;
		for(int v=0;v<n;v++)
		{
			if(val[u][v] != INF and done[v] == false)
			{
				if(d[v] > d[u] + val[u][v])
				{
					d[v] = d[u] + val[u][v];
				}
			}
		}
	}

	return d[gg];
}

signed main(){
	while(cin >> n >> m >> c >> s >> g and !(n==0 and m==0 and c==0 and s==0 and g==0)){
		s--, g--;

		for(int i=0;i<25;i++)
			for(int j=0;j<105;j++)
				for(int k=0;k<105;k++)
				{
					dist[i][j][k]=INF;
					if(j==k) dist[i][j][k]=0;
				}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				val[i][j]=INF;
				if(i==j) val[i][j] = 0;
			}

		for(int i=0;i<m;i++)
		{
			int x,y,d,cc;
			cin >> x >> y >> d >> cc;
			x--;y--;cc--;
			dist[cc][x][y]=min(d, dist[cc][x][y]);
			dist[cc][y][x]=min(d, dist[cc][y][x]);
		}
		
		for(int i=0; i<c; i++){
			cin>>p[i];
		}
		
		for(int i=0;i<c;i++){
			vector<int> q(p[i]);
			vector<int> r(p[i]);
			for(int j=0; j<p[i]-1; j++){
				cin>>q[j];
			}
			for(int j=0; j<p[i]; j++){
				cin>>r[j];
			}
			dtov[i][0] = 0;
			int cr = 0;
			for(int j=1; j<20005; j++){
				dtov[i][j] = dtov[i][j-1]+r[cr];
				if (j==q[cr]) cr++;
			}
		}

		for(int i=0;i<c;i++)
		{
			for(int k=0;k<n;k++)
				for(int j=0;j<n;j++)
					for(int l=0;l<n;l++)
						dist[i][j][l]=min(dist[i][j][l],dist[i][j][k]+dist[i][k][l]);

			for(int j=0;j<n;j++)
				for(int k=0;k<n;k++)
				{
					if(dist[i][j][k]>=INF)
						continue;
					val[j][k]=min(val[j][k],dtov[i][dist[i][j][k]]);

				}
		}

		/*
		for(int i=0;i<c;i++)
		{
			cout << "c = " << i << endl;
			for(int j=0;j<n;j++)
			{
				for(int k=0;k<n;k++)
				{
					cout << ( (dist[i][j][k]!=INF)? dist[i][j][k] : -1) << " ";
				}
				cout << endl;
			}
		}
		cout << "dtov" << endl;
		for(int i=0;i<c;i++)
		{
			cout << "i=" << i << endl;
			for(int j=0;j<10;j++)
			{
				cout << dtov[i][j] << " ";
			}
			cout << endl;
		}

		cout << "valです〜" << endl;
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				if(val[j][k]!=INF) cout << val[j][k] << " ";
				else cout << "INF" << " ";
			}
		cout << endl;
		}
		*/
		int ans = dij(s,g);
		cout << ( (ans==INF)? -1 : ans ) << endl;
	}
}
