#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
const int INF = 1000 * 1000 * 1000;
int n, m, c, start, goal;
struct edge{
    int u, v, cost, com;
    edge() {}
    edge(int u, int v, int c, int cc) : 
        u(u), v(v), cost(c), com(cc) {}
};
struct S{
    int u, lastc, coin;
    S() {}
    S(int u, int l, int coin):
        u(u), lastc(l), coin(coin) {}
    bool operator < (const S& s) const {
        return coin > s.coin;
    }
};
typedef vector<edge> edges;
typedef vector<edges> graph;
int calc(vector<int> q, vector<int> r, int d){
    q.push_back(INF);
    int sum = 0;
    REP(i, q.size()-1){
        if(q[i] <= d && d < q[i+1]){
            return (d - q[i]) * r[i] + sum;
        }else{
            sum += (q[i+1]-q[i]) * r[i];
        }
    }

}
typedef pair<int, int> P;
            
int main(){
    while(cin>>n>>m>>c>>start>>goal && (n||m||c)){
        //printf("%d %d %d %d %d\n", n, m, c, start, goal);
        start--; goal--;
        graph g(n);
        REP(i, m){
            int x, y, d, c;
            cin>>x>>y>>d>>c;
            x--; y--; c--;
            g[x].push_back(edge(x, y, d, c));
            g[y].push_back(edge(y, x, d, c));
        }
        vector<int> p(c);
        REP(i, c) cin>>p[i];
        vector<int> q[20];
        vector<int> r[20];
        REP(i, c){
            q[i].push_back(0);
            REP(j, p[i]-1){
                int t; cin>>t;
                q[i].push_back(t);
            }
            REP(j, p[i]){
                int t; cin>>t;
                r[i].push_back(t);
            }
        }
        int dist[100][20];
        REP(i, 100)REP(j, 20) dist[i][j] = INF;
        priority_queue<S> que;
        que.push(S(start, -1, 0));
        bool ok = false;
        while(!que.empty()){
            S st = que.top(); que.pop();
            //printf("station:%d use:%d lastcompany:%d\n", st.u, st.coin, st.lastc);
            if(st.u == goal){
                cout<< st.coin << endl;
                ok = true;
                break;
            }
            REP(i, c)if(st.lastc != i){
                int nowcomp = i;
                queue<P> que2;
                que2.push(P(st.u, 0));
                while(!que2.empty()){
                    P p = que2.front(); que2.pop();
                    int u = p.first; int d = p.second;
                    FORIT(it, g[u])if(it->com == nowcomp){
                        int nextd = d + it->cost;
                        int calcd = calc(q[nowcomp], r[nowcomp], nextd) + st.coin;
                        if(dist[it->v][nowcomp] > calcd){
                            dist[it->v][nowcomp] = calcd;
                            que.push(S(it->v, nowcomp, calcd));
                            que2.push(P(it->v, nextd));
                            //que2.push(P(it->v, 0)); // ok???
                        }
                    }
                }
            }
        }
        if(!ok) cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 2252