#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e18;


int main(){

    while(1){

        //入力受け取り
        long long n, m, c, s, g; cin >> n >> m >> c >> s >> g;
        if(!n) break;
        
        vector<long long> x(m);
        vector<long long> y(m);
        vector<long long> d(m);
        vector<long long> C(m);
        for(long long i = 0; i < m; i++) cin >> x[i] >> y[i] >> d[i] >> C[i];

            

        vector<long long> p(c);
        for(long long i = 0; i < c; i++) cin >> p[i];

        vector<vector<long long> > q(c);
        vector<vector<long long> > r(c);
        vector<vector<long long> > b(c);
        for(long long i = 0; i < c; i++){
            
            q[i].push_back(0);

            for(long long j = 0; j < p[i] - 1; j++){
                long long in; cin >> in; q[i].push_back(in);
            }

            for(long long j = 0; j < p[i]; j++){
                long long in; cin >> in; r[i].push_back(in);
            }
        }
        //入力終了
        //入力が複雑なのでそのまま受け取る

        //まず鉄道会社ごとに距離でワーシャルフロイド
        vector<vector<vector<long long> > > dis(n, vector<vector<long long> > (n, vector<long long> (c, INF)));


        //n(i) → n(i)　を 0で初期化
        for(long long k = 0; k < c; k++){
            for(long long i = 0; i < n; i++){
                dis[i][i][k] = 0;
            }
        }
        
        //入力を反映させる
        for(long long i = 0; i < m; i++){
            dis[x[i] - 1][y[i] - 1][C[i] - 1] = min(dis[x[i] - 1][y[i] - 1][C[i] - 1], d[i]);
            dis[y[i] - 1][x[i] - 1][C[i] - 1] = min(dis[x[i] - 1][y[i] - 1][C[i] - 1], d[i]);            
        }


        //ワーシャルフロイド
        for(long long l = 0; l < c; l++){
            for(long long k = 0; k < n; k++){
                for(long long i = 0; i < n; i++){
                    for(long long j = 0; j < n; j++){
                        dis[i][j][l] = min(dis[i][j][l], dis[i][k][l] + dis[k][j][l]);
                    }
                }
            }
        }

        /*for(int i = 0; i < p[0]; i++){
            cout << q[0][i] << " " << r[0][i] << endl;
        }*/

        //各Cについて、bをけいさん
        for(long long l = 0; l < c; l++){
            b[l].push_back(0);
            for(long long i = 1; i < p[l]; i++){
                b[l].push_back(b[l][i - 1] + (q[l][i] - q[l][i - 1]) * r[l][i - 1]);
                //cout << l << " " << i << " " << b[l][i] << endl;
            }
            //cout << endl;
        }
        /*cout << endl;
        for(int i = 0; i < b[0].size(); i++){
            cout << b[0][i] << " ";
        }
        cout << endl;

        
        for(int i = 0; i < b[1].size(); i++){
            cout << b[1][i] << " ";
        }
        cout << endl;
        */
        //cout << endl;

        //次に最短距離を使って料金を決めていく（一番難しい）
        //二部探索はさぼる
        for(long long l = 0; l < c; l++){
            for(long long i = 0; i < n; i++){
                for(long long j = 0; j < n; j++){
                    
                    if(dis[i][j][l] >= INF) continue;

                    //??のkを見つける
                    long long k = 0;
                    for(; k < p[l]; k++){
                        if(q[l][k] >= dis[i][j][l]){
                            break;
                        }
                    }
                    if(k > 0) k--;

                    dis[i][j][l] = b[l][k] + (dis[i][j][l] - q[l][k]) * r[l][k];
                }
            }
        }

        
        /*for(long long k = 0; k < c; k++){

            for(long long i = 0; i < n; i++){
                for(long long j = 0; j < n; j++){
                    cout << dis[i][j][k] << " ";
                }
                cout << endl;
            }
            cout << endl;
        }*/

        //料金のワーシャルフロイド
        vector<vector<long long> > cost(n, vector<long long> (n, INF));;
        for(long long l = 0; l < c; l++){
            for(long long i = 0; i < n; i++){
                for(long long j = 0; j < n; j++){
                    cost[i][j] = min(cost[i][j], dis[i][j][l]);
                    
                    if(i == j) cost[i][j] = 0;
                }
            }
        }   
    
        for(long long k = 0; k < n; k++){
            for(long long i = 0; i < n; i++){
                for(long long j = 0; j < n; j++){
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                }
            }
        }

        if(cost[s - 1][g - 1] >= INF) cout << -1 << endl;
        else cout << cost[s - 1][g - 1] << endl;

    }

    return 0;
}


Measured memory_bytes: 5188