#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL INF=1<<28;


int q[50][20],r[50][20],p[20];

int f(int d,int k){
    int ret = 0;
    for (int i = 0; i < p[k]; i++) {
        if(d<=q[i][k]){
            if(i==0) ret+=d*r[i][k];
            else ret+=(d-q[i-1][k])*r[i][k];
            break;
        }
        else{
            if(i==0) ret+=q[i][k]*r[i][k];
            else ret+=(q[i][k]-q[i-1][k])*r[i][k];
        }
    }
    return ret;
}

struct edge {int to;LL cost;};

const int M_N=100002;

vector<edge> G[M_N+1];
LL dd[M_N+1];

struct Dijkstra{

    void dijkstra(int s){
        priority_queue<P,vector<P>,greater<P>> que;
        que.push(P(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(dd[v]<p.first) continue;
            for(int i=0;i<G[v].size();i++){
                edge e=G[v][i];
                if(dd[e.to]>dd[v]+e.cost){
                    dd[e.to]=dd[v]+e.cost;
                    que.push(P(dd[e.to],e.to));
                }
            }
        }
    }

};


int main(){
    int n,m,c,s,g;
    while(cin >> n >> m >> c >> s >> g){
        if(!n&&!m&&!c&&!s&&!g) break;
        s--,g--;
        int v[n][n][c];
        for (int k = 0; k < c; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    v[i][j][k]=INF;
                }
            }
        }
        for (int i = 0; i < m; i++) {
            int x,y,d,C;cin >> x >> y >> d >> C;
            x--,y--,C--;
            v[x][y][C]=min(v[x][y][C],d);
            v[y][x][C]=min(v[x][y][C],d);
        }
        for (int i = 0; i < c; i++) {
            cin >> p[i];
        }
        for (int i = 0; i < c; i++) {
            for (int j = 0; j < p[i]-1; j++) {
                cin >> q[j][i];
            }
            q[p[i]-1][i]=INF;
            for (int j = 0; j < p[i]; j++) {
                cin >> r[j][i];
            }
        }
        int dist[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dist[i][j]=INF;
            }
        }
        for (int l = 0; l < c; l++) {
            for (int k = 0; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        v[i][j][l]=min(v[i][j][l],v[i][k][l]+v[k][j][l]);
                    }
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < c; k++) {
                    if(v[i][j][k]==INF) continue;
                    dist[i][j]=min(dist[i][j],f(v[i][j][k],k));
                }
            }
        }
        for (int i = 0; i < M_N; i++) {
            G[i].clear();
        }
        Dijkstra ds;
        fill(dd,dd+M_N,INF);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                G[i].pb({j,dist[i][j]});
            }
        }
        dd[s]=0;
        ds.dijkstra(s);
        if(dd[g]==INF) puts("-1");
        else cout << dd[g] << endl;
    }
    return 0;
}




Measured memory_bytes: 7280