#include<stdio.h>
#define MAX_N 100
#define MAX_M 10000
#define MAX_D 200
#define MAX_C 20
#define MAX_AREA 50
#define MAX_Q 10000
#define MAX_R 100
#define INF 1000000000
int n, m, nc, s, g;
int p[MAX_C],q[MAX_C][MAX_AREA],r[MAX_C][MAX_AREA],sc[MAX_C][MAX_AREA];
int dist[MAX_C][MAX_N][MAX_N];
void wf(int c){
    int i,j,k;
    for(k=0;k<n;k++){
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                if(dist[c][i][j]>dist[c][i][k]+dist[c][k][j])
                    dist[c][i][j]=dist[c][i][k]+dist[c][k][j];
            }
        }
    }
}
int cost(int c,int d){
    int i,uc=0;
    if(d==0) return 0;
    if(d==INF) return INF;
    for(i=p[c]-1;i>=0;i--){
        if(d>q[c][i]) break;
    }
    return sc[c][i]+(d-q[c][i])*r[c][i];
}
void dtoc(int c){
    int i,j,d;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            dist[c][i][j]=cost(c,dist[c][i][j]);
}
void solve(){
    int i,j,c;
    for(i=0;i<nc;i++){
        wf(i);
        dtoc(i);
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            for(c=1;c<nc;c++){
                if(dist[c][i][j]<dist[0][i][j])
                    dist[0][i][j]=dist[c][i][j];
            }
        }
    }
    wf(0);
    if(dist[0][s-1][g-1]==INF)
        printf("-1\n");
    else
        printf("%d\n",dist[0][s-1][g-1]);
}
void init(){
    int i,j,k;
    for(i=0;i<MAX_C;i++){
        p[i]=0;
        for(j=0;j<MAX_AREA;j++)
            q[i][j]=r[i][j]=0;
    }
    for(i=0;i<MAX_C;i++){
        for(j=0;j<MAX_N;j++){
            for(k=j;k<MAX_N;k++){
                if(j==k) dist[i][j][k]=0;
                else dist[i][j][k]=dist[i][k][j]=INF;
            }
        }
    }
}
int main(void){
    int i,j;
    int x,y,d,c;
    while(1){
        scanf("%d%d%d%d%d",&n,&m,&nc,&s,&g);
        if(n==0&&m==0&&nc==0&&s==0&&g==0) break;
        init();
        for(i=0;i<m;i++){
            scanf("%d%d%d%d",&x,&y,&d,&c);
            if(dist[c-1][x-1][y-1]>d)
                dist[c-1][x-1][y-1]=dist[c-1][y-1][x-1]=d;
        }
        for(i=0;i<nc;i++)
            scanf("%d",&p[i]);
        for(i=0;i<nc;i++){
            for(j=1;j<p[i];j++)
                scanf("%d",&q[i][j]);
            q[i][0]=0;
            for(j=0;j<p[i];j++)
                scanf("%d",&r[i][j]);
            sc[i][0]=0;
            for(j=1;j<p[i];j++)
                sc[i][j]=sc[i][j-1]+(q[i][j]-q[i][j-1])*r[i][j-1];
        }
        solve();
    }
}

