#include <stdio.h>

#define inf 1000000000

struct company_info{
	int rail[100][100];
	int p;
	int dst[51];
	int cost[20001];
};

int n, m, c, s, g;
struct company_info company[20];
int i, j, k, l;
int x, y, d, ci;
int r;
int dp[100][100];

int main(){
	while(1){
		scanf("%d %d %d %d %d", &n, &m, &c, &s, &g);
		if(n==0) break;

		s--; g--;

		for(k=0; k<c; k++){
			for(i=0; i<n; i++){
				for(j=0; j<n; j++){
					if(i==j){
						company[k].rail[i][j] = 0;
						dp[i][j] = 0;
					}else{
						company[k].rail[i][j] = inf;
						dp[i][j] = inf;
					}
				}
			}
		}

		for(i=0; i<m; i++){
			scanf("%d %d %d %d", &x, &y, &d, &ci);
			x--; y--; ci--;
			if(company[ci].rail[x][y]>d){
				company[ci].rail[x][y] = company[ci].rail[y][x] = d;
			}
		}

		for(i=0; i<c; i++){
			scanf("%d", &(company[i].p));
		}

		for(i=0; i<c; i++){
			for(j=1; j<company[i].p; j++){
				scanf("%d", &(company[i].dst[j]));
			}
			company[i].dst[j] = 20000;
			k = 1;
			company[i].cost[0] = 0;
			for(j=1; j<=company[i].p; j++){
				scanf("%d", &r);
				for(k; k<=company[i].dst[j]; k++){
					company[i].cost[k] = company[i].cost[k-1] + r;
				}
			}
		}

		for(l=0; l<c; l++){
			for(k=0; k<n; k++){
				for(i=0; i<n; i++){
					for(j=0; j<n; j++){
						if(company[l].rail[i][j]>company[l].rail[i][k] + company[l].rail[k][j]){
							company[l].rail[i][j] = company[l].rail[i][k] + company[l].rail[k][j];
						}
					}
				}
			}
			for(i=0; i<n; i++){
				for(j=0; j<n; j++){
					if(company[l].rail[i][j]!=inf){
						company[l].rail[i][j] = company[l].cost[company[l].rail[i][j]];
						if(dp[i][j]>company[l].rail[i][j]){
							dp[i][j] = company[l].rail[i][j];
						}
					}
				}
			}
		}

		for(k=0; k<n; k++){
			for(i=0; i<n; i++){
				for(j=0; j<n; j++){
					if(dp[i][j]>dp[i][k] + dp[k][j]){
						dp[i][j] = dp[i][k] + dp[k][j];
					}
				}
			}
		}
		if(dp[s][g]!=inf){
			printf("%d\n", dp[s][g]);
		}else{
			printf("-1\n");
		}
	}

	return 0;
}