#include <stdio.h>
#include <stdlib.h>

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)

#define min(x,y) x<y?x:y
#define minch(x,y) x=min(x,y)

#define INF 999999999

int n,m,c,s,g;
int d[22][111][111];
int cost[22][22222];
int dc[111][111];

int main(){
	//cin.sync_with_stdio(false);
	while(1){
		scanf("%d%d%d%d%d",&n,&m,&c,&s,&g);
		if(n==0)break;
		s--; g--;
		rep(i,22)rep(j,111)rep(k,111)d[i][j][k]=(j==k?0:INF);
		rep(i,m){
			int x,y,dd,cmp;
			scanf("%d%d%d%d",&x,&y,&dd,&cmp);
			x--; y--; cmp--;
			d[cmp][x][y]=d[cmp][y][x]=min(dd,d[cmp][x][y]);
		}
		int p[22];
		rep(i,c){
			scanf("%d",p+i);
			//dbg(p[i]);
		}
		rep(i,c){
			int q[55],r[55];
			rep(j,p[i]-1)scanf("%d",q+j);
			rep(j,p[i])scanf("%d",r+j);
			int nq=0;
			cost[i][0]=0;
			rep(dd,20010){
				if(nq<p[i]-1&&dd==q[nq])nq++;
				cost[i][dd+1]=cost[i][dd]+r[nq];
				//if(dd<10)dbg(cost[i][dd]);
			}
		}
		rep(cmp,c)rep(k,n)rep(i,n)rep(j,n)minch(d[cmp][i][j],d[cmp][i][k]+d[cmp][k][j]);
		rep(i,n)rep(j,n)dc[i][j]=(i==j?0:INF);
		rep(i,c)rep(j,n)rep(k,n)if(d[i][j][k]!=INF)minch(dc[j][k],cost[i][d[i][j][k]]);
		rep(k,n)rep(i,n)rep(j,n)minch(dc[i][j],dc[i][k]+dc[k][j]);
		if(dc[s][g]==INF)printf("-1\n");
		else printf("%d\n", dc[s][g]);
	}
	return 0;
}