#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
#include<string>
#include<functional>

using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n,m,c,s,g;
int x,y,d,ct;
int p[21],q[21][61],r[21][61];
int fie[101][101][21];
int fie2[101][101];
int dp[101];

int dijk(){
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,s));
	while(que.size()){
		P q=que.top();
		que.pop();
		int cost=q.first,place=q.second;
		if(dp[place]<cost)continue;
		dp[place]=cost;
		if(place==g)return cost;
		for(int i=1;i<=n;i++){
			int ncost=cost+fie2[place][i];
			if(ncost<dp[i]){
				dp[i]=ncost;
				que.push(P(ncost,i));
			}
		}
	}
	return -1;
}

int main(void){
	while(1){
		scanf("%d%d%d%d%d",&n,&m,&c,&s,&g);
		if(n+m+c+s+g==0)break;
		for(int i=0;i<=20;i++){
			q[i][0]=0;
			for(int j=1;j<=60;j++)q[i][j]=514514191;
			for(int j=0;j<=100;j++){
				for(int k=0;k<=100;k++)fie[j][k][i]=514514191;
				fie[j][j][i]=0;
			}
		}
		for(int i=0;i<=100;i++){
			dp[i]=514514191;
			for(int j=0;j<=100;j++)fie2[i][j]=514514191;
			fie2[i][i]=0;
		}
		for(int i=0;i<m;i++){
			scanf("%d%d%d%d",&x,&y,&d,&ct);
			fie[x][y][ct]=min(fie[x][y][ct],d);
			fie[y][x][ct]=min(fie[y][x][ct],d);
		}
		for(int i=1;i<=c;i++)scanf("%d",&p[i]);
		for(int i=1;i<=c;i++){
			for(int j=1;j<p[i];j++)scanf("%d",&q[i][j]);
			for(int j=0;j<p[i];j++)scanf("%d",&r[i][j]);
		}
		for(int l=1;l<=c;l++){
			for(int k=1;k<=n;k++){
				for(int i=1;i<=n;i++){
					for(int j=1;j<=n;j++)fie[i][j][l]=min(fie[i][j][l],fie[i][k][l]+fie[k][j][l]);
				}
			}
		}
		for(int l=1;l<=c;l++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					int lx=0,cost=0;
					if(fie[i][j][l]==514514191)continue;
					while(q[l][lx]<fie[i][j][l]){
						if(q[l][lx+1]<fie[i][j][l])cost+=(q[l][lx+1]-q[l][lx])*r[l][lx];
						else cost+=(fie[i][j][l]-q[l][lx])*r[l][lx];
						lx++;
					}
					fie[i][j][l]=cost;
				}
			}
		}
		for(int l=1;l<=c;l++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++)fie2[i][j]=min(fie2[i][j],fie[i][j][l]);
			}
		}
		printf("%d\n",dijk());
	}
	return 0;
}