#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N,M,company,start,goal,num_oresen[25],loc[52],value[52],cost_table[20002];
int*** cost;
int final_cost[101][101];

void func(){

	if(M == 0){
		for(int i = 1; i <= company; i++)scanf("%d",&num_oresen[i]);
		for(int com = 1; com <= company; com++){
			for(int i = 1; i <= num_oresen[com]-1; i++)scanf("%d",&loc[i]);
			for(int i = 1; i <= num_oresen[com]; i++)scanf("%d",&value[i]);
		}

		if(start != goal)printf("-1\n");
		else{
			printf("0\n");
		}
		return;
	}


	for(int i = 1; i <= company;i++){
		for(int k = 1; k <= N; k++){
			for(int p = 1; p <= N; p++){
				if(k != p)cost[i][k][p] = BIG_NUM;
				else{
					cost[i][k][p] = 0;
				}
			}
		}
	}

	int from,to,dist,tmp_com;

	for(int i = 0; i < M; i++){
		scanf("%d %d %d %d",&from,&to,&dist,&tmp_com);
		cost[tmp_com][from][to] = min(cost[tmp_com][from][to],dist);
		cost[tmp_com][to][from] = min(cost[tmp_com][to][from],dist);
	}

	int max_dist = 0;

	for(int com = 1; com <= company;com++){
		for(int mid = 1; mid <= N; mid++){
			for(int st = 1; st <= N; st++){
				if(cost[com][st][mid] == BIG_NUM)continue;
				for(int gl = 1; gl <= N; gl++){
					if(cost[com][mid][gl] == BIG_NUM)continue;
					cost[com][st][gl] = min(cost[com][st][gl],cost[com][st][mid]+cost[com][mid][gl]);
					max_dist = max(max_dist,cost[com][st][gl]);
				}
			}
		}
	}

	for(int i = 1; i <= company;i++){
		scanf("%d",&num_oresen[i]);
	}

	int index;

	for(int com = 1; com <= company; com++){
		for(int i = 1; i <= num_oresen[com]-1; i++)scanf("%d",&loc[i]);
		for(int i = 1; i <= num_oresen[com]; i++)scanf("%d",&value[i]);

		index = 0;
		cost_table[0] = 0;

		for(int dist = 1; dist <= max_dist+1; dist++){
			if(dist <= loc[index]){
				cost_table[dist] = cost_table[dist-1]+value[index];
			}else{
				index = min(index+1,num_oresen[com]);
				cost_table[dist] = cost_table[dist-1]+value[index];
			}
		}


		for(int i = 1; i <= N; i++){
			for(int k = 1; k <= N; k++){
				if(i != k && cost[com][i][k] != BIG_NUM){
					cost[com][i][k] = cost_table[cost[com][i][k]];
				}
			}
		}
	}

	for(int i = 1; i <= N; i++){
		for(int k = 1; k <= N; k++){
			if(i != k)final_cost[i][k] = BIG_NUM;
			else{
				final_cost[i][k] = 0;
			}
		}
	}

	for(int i = 1; i <= N; i++){
		for(int k = 1; k <= N; k++){
			for(int com = 1; com <= company;com++){
				final_cost[i][k] = min(final_cost[i][k],cost[com][i][k]);
			}
		}
	}

	for(int mid = 1; mid <= N; mid++){
		for(int st = 1; st <= N; st++){
			if(final_cost[st][mid] == BIG_NUM)continue;
			for(int gl = 1; gl <= N; gl++){
				if(final_cost[mid][gl] == BIG_NUM)continue;
				final_cost[st][gl] = min(final_cost[st][gl],final_cost[st][mid]+final_cost[mid][gl]);
			}
		}
	}


	if(final_cost[start][goal]  != BIG_NUM)printf("%d\n",final_cost[start][goal]);
	else{
		printf("-1\n");
	}
}

int main(){

	cost = new int**[21];
	for(int i = 1; i <= 20; i++){
		cost[i] = new int*[101];
		for(int k = 1; k <= 100; k++)cost[i][k] = new int[101];
	}

	while(true){
		scanf("%d %d %d %d %d",&N,&M,&company,&start,&goal);
		if(N == 0 && M == 0 && company == 0 && start == 0 && goal == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 4080