#include<bits/stdc++.h>
using namespace std;

using Weight=long long;
const Weight INF=1e9;

struct Edge{
    int to;
    Weight cost;
};

using Edges=vector<Edge>;
using Graph=vector<Edges>;

const int FIRM=25;
int vertex(int v,int c){
    return v*FIRM+c;
}

void dijkstra(int s,Graph& g,vector<Weight> &d){
    d.assign(g.size(),INF);
    priority_queue<pair<Weight,int>,vector<pair<Weight,int>>,greater<>> que;
    que.push({0,s});
    d[s]=0;
    while(!que.empty()){
        auto ret=que.top(); que.pop();
        int v=ret.second;
        if(d[v]<ret.first) continue;
        for(int i=0;i<g[v].size();i++){
            int to=g[v][i].to;
            if(d[to]>d[v]+g[v][i].cost){
                d[to]=d[v]+g[v][i].cost;
                que.push({d[to],to});
            }
        }
    }
    return;
}
int main(){
    int n,m,c,s,gg;
    while(cin>>n>>m>>c>>s>>gg,n){
        s--,gg--;
        vector<vector<vector<Weight>>> dist(c,vector<vector<Weight>>(n,vector<Weight>(n,INF)));
        for(int i=0;i<m;i++){
            int x,y;
            Weight d;
            int cc;
            cin>>x>>y>>d>>cc;
            x--,y--,cc--;
            dist[cc][x][y]=min(dist[cc][x][y],d);
            dist[cc][y][x]=min(dist[cc][x][y],d);
        }

        for(int k=0;k<c;k++)for(int i=0;i<n;i++) dist[k][i][i]=0;

        vector<int> p(c);
        for(int i=0;i<c;i++) cin>>p[i];
        vector<vector<Weight>> q(c);
        vector<vector<Weight>> r(c);
        for(int i=0;i<c;i++){
            q[i].assign(p[i]+1,0);
            q[i][0]=0;
            q[i][p[i]]=INF;
            for(int j=0;j<p[i]-1;j++){
                cin>>q[i][j+1];
            }
            r[i].assign(p[i],0);
            for(int j=0;j<p[i];j++){
                cin>>r[i][j];
            }
        }
        
        

        Graph g(n*FIRM);

        for(int i=0;i<n;i++){
            for(int j=0;j+1<FIRM;j++){
                g[vertex(i,j)].push_back(Edge{vertex(i,FIRM-1),Weight(0)});
                g[vertex(i,FIRM-1)].push_back(Edge{vertex(i,j),Weight(0)});
            }
        }

        for(int firm=0;firm<c;firm++){
            for(int k=0;k<n;k++){
                for(int i=0;i<n;i++){
                    for(int j=0;j<n;j++){
                        dist[firm][i][j]=min(dist[firm][i][j],dist[firm][i][k]+dist[firm][k][j]);
                    }
                }
            }

            auto getCost=[&](Weight dis){
                if(dis>=INF) return INF;
                Weight res=0;
                for(int i=0;i<p[firm];i++){
                    if(dis<q[firm][i+1]){
                        return res+(dis-q[firm][i])*r[firm][i];
                    }
                    res+=(q[firm][i+1]-q[firm][i])*r[firm][i];                    
                }
                return INF;
            };
            
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    Weight cost=getCost(dist[firm][i][j]);
                    g[vertex(i,firm)].push_back(Edge{vertex(j,firm),cost});
                }
            }
        }
        vector<Weight> dvec(n*FIRM);
        dijkstra(vertex(s,FIRM-1),g,dvec);
        Weight res=dvec[vertex(gg,FIRM-1)];
        if(res>=INF) cout<<-1<<endl;
        else cout<<res<<endl;

    }

    return 0;
}


Measured memory_bytes: 10856