#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define INF 1000000000

typedef const vector<int> &rvint;
typedef vector<vector<int> > vvint;

void WF(vvint &v){
	int n = v.size();
	for(int k = 0; k < n; ++k)
	for(int i = 0; i < n; ++i)
	for(int j = i + 1; j < n; ++j){
		v[i][j] = v[j][i] = min(v[i][j], v[i][k] + v[k][j]);
	}
}

int calccost(rvint r, rvint q, rvint sumdc, int d){
	if( d == INF ) return INF;

	int x = upper_bound(q.begin(), q.end(), d) - q.begin() - 1;
	return sumdc[x] + r[x] * (d - q[x]);
}

int main(){
	int n, m, c, s, g;
	int x, y, d, cm;
	int p[20];
	while( scanf("%d%d%d%d%d", &n, &m, &c, &s, &g), n != 0 ){
		vector<vvint> mindist(c, vvint(n, vector<int>(n, INF) ) );
		vvint mincost(n, vector<int>(n, INF) );
		
		for(int i = 0; i < m; ++i){
			scanf("%d%d%d%d", &x, &y, &d, &cm);
			--x; --y; --cm;
			d = min(d, mindist[cm][x][y]);
			mindist[cm][x][y] = mindist[cm][y][x] = d;
		}
		
		for(int i = 0; i < c; ++i){
			scanf("%d", &p[i]);
		}
		
		for(int i = 0; i < c; ++i){
			vector<int> sumdc(p[i]), r(p[i]), q(p[i]);
			for(int j = 1; j < p[i]; ++j){
				scanf("%d", &q[j]);
			}
			for(int j = 0; j < p[i]; ++j){
				scanf("%d", &r[j]);
			}
			
			for(int j = 1; j < p[i]; ++j){
				sumdc[j] = sumdc[j-1] + (q[j] - q[j-1]) * r[j-1];
			}

			WF(mindist[i]);
			
			for(int j = 0; j < n; ++j)
			for(int k = j + 1; k < n; ++k){
				int a = calccost(r, q, sumdc, mindist[i][j][k]);
				mincost[j][k] = mincost[k][j] = min(mincost[j][k], a);
			}
		}

		WF(mincost);
		int ans = mincost[s-1][g-1];
		printf("%d\n", ans < INF ? ans : -1);
	}
}