//AOJ1182 鉄道乗り継ぎ
//https://onlinejudge.u-aizu.ac.jp/problems/1182
//所要時間:解法を思いつくのに1時間半、
/*
全ての鉄道会社xについてxの路線のみを使って任意の2駅間を行き来する最小コストをWarshall-Floyd法により求めておく。
それによってできたグラフに対してdijkstra法を適用し目的の最小コストを求める。
*/


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


template<typename T>
struct WarshallFloyd {
    vector<vector<T>> ds;
    vector<vector<int>> next;
    WarshallFloyd() = default;
    WarshallFloyd(int n) : ds(n, vector<T>(n, numeric_limits<T>::max())), next(n, vector<int>(n)){
        for(int i = 0;i < n;++i) ds[i][i] = 0;
        for(int i = 0;i < n;++i) for(int j = 0;j < n;++j) next[i][j] = j;
    }
    void addEdge(int u, int v, T c){
        ds[u][v] = min(ds[u][v], c);
    }
    void build(){
        int n = ds.size();
        for(int k = 0;k < n;++k) for(int i = 0;i < n;++i){
            if(ds[i][k] == numeric_limits<T>::max()) continue;
            for(int j = 0;j < n;++j){
                if(ds[k][j] == numeric_limits<T>::max()) continue;
                if(ds[i][j] > ds[i][k]+ds[k][j]) ds[i][j] = ds[i][k]+ds[k][j], next[i][j] = next[i][k];
            }
        }
    }
    const vector<T>& operator[](int n) const { return ds[n]; }
    vector<int> restore(int from, int to){
        vector<int> res;
        while(from != to) res.push_back(from), from = next[from][to];
        res.push_back(to);
        return res;
    }
    bool negativeCycle(){
        int n = ds.size();
        for(int i = 0;i < n;++i) if(ds[i][i] < 0) return true;
        return false;
    }
};


template<typename T>
struct Dijkstra {
    struct Edge {
        int to;
        T cost;
        Edge(int to, T cost) : to(to), cost(cost){}
        bool operator<(const Edge& e) const { return cost > e.cost; }
    };
    vector<vector<Edge>> G;
    vector<T> ds;
    vector<int> bs;
    Dijkstra() = default;
    Dijkstra(int n) : G(n){}
    void addEdge(int u, int v, T c){
        G[u].emplace_back(v, c);
    }
    void build(int s){
        int n = G.size();
        ds.assign(n, numeric_limits<T>::max());
        bs.assign(n, -1);
        priority_queue<Edge> pq;
        ds[s] = 0;
        pq.emplace(s, ds[s]);
        while(!pq.empty()){
            auto p = pq.top(); pq.pop();
            int v = p.to;
            if(ds[v] < p.cost) continue;
            for(auto e : G[v]){
                if(ds[e.to] > ds[v]+e.cost){
                    ds[e.to] = ds[v]+e.cost;
                    bs[e.to] = v;
                    pq.emplace(e.to, ds[e.to]);
                }
            }
        }
    }
    T operator[](int k){ return ds[k]; }
    vector<int> restore(int to){
        vector<int> res;
        if(bs[to] < 0) return res;
        while(~to) res.emplace_back(to), to = bs[to];
        reverse(begin(res), end(res));
        return res;
    }
};


constexpr int INF = numeric_limits<int64_t>::max();


int32_t main(){
    int n, m, c, s, g;
    while(cin >> n >> m >> c >> s >> g, n){
        s--;
        g--;
        vector<WarshallFloyd<int>> ds(c, WarshallFloyd<int>(n));
        for(int i = 0;i < m;++i){
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            x--;
            y--;
            c--;
            ds[c].addEdge(x, y, d);
            ds[c].addEdge(y, x, d);
        }
        for(int i = 0;i < c;++i) ds[i].build();
        vector<int> p(c);
        vector<vector<int>> f(c, vector<int>(20010));
        for(int i = 0;i < c;++i) cin >> p[i];
        for(int i = 0;i < c;++i){
            vector<int> q(p[i]+1), r(p[i]);
            for(int j = 1;j < p[i];++j) cin >> q[j];
            q[p[i]] = 20000;
            for(int j = 0;j < p[i];++j) cin >> r[j];
            for(int j = 0;j < p[i];++j) for(int k = q[j];k < q[j+1];k++) f[i][k+1] = f[i][k] + r[j];
        }
        Dijkstra<int> G(n);
        for(int i = 0;i < c;++i) for(int j = 0;j < n;++j) for(int k = j+1;k < n;++k){
            if(ds[i][j][k] >= INF) continue;
            int d = min(ds[i][j][k], 20000LL);
            G.addEdge(j, k, f[i][d]), G.addEdge(k, j, f[i][d]);
        }
        G.build(s);
        if(G[g] < INF) cout << G[g] << endl;
        else cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 12900