#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

constexpr int INF = 1e9;

struct edge {
    int to, cost, line;
};

using edges = vector<edge>;
using graph = vector<edges>;

struct state {
    int v, line, count, cost;
    bool operator>(state const& other) const {
        return cost > other.cost;
    }
};

int main() {
    int N, M, C, S, G;
    while(cin >> N >> M >> C >> S >> G, N) {
        S--; G--;
        graph g(N);
        vector<vector<vector<int>>> tmpd(C, vector<vector<int>>(N, vector<int>(N, INF)));
        for(int c=0; c<C; ++c) {
            for(int i=0; i<N; ++i) {
                tmpd[c][i][i] = 0;
            }
        }
        for(int i=0; i<M; ++i) {
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            x--; y--; --c;
            tmpd[c][x][y] = tmpd[c][y][x] = min(tmpd[c][x][y], d);
        }
        for(int c=0; c<C; ++c) {
            for(int k=0; k<N; ++k) {
                for(int i=0; i<N; ++i) {
                    for(int j=0; j<N; ++j) {
                        tmpd[c][i][j] = min(tmpd[c][i][j], tmpd[c][i][k] + tmpd[c][k][j]);
                    }
                }
            }
        }
        for(int i=0; i<N; ++i) {
            for(int j=i; j<N; ++j) {
                for(int c=0; c<C; ++c) {
                    if(tmpd[c][i][j] != INF) {
                        g[i].push_back((edge){j, tmpd[c][i][j], c});
                        g[j].push_back((edge){i, tmpd[c][i][j], c});
                    }
                }
            }
        }
        vector<int> p(C);
        for(int i=0; i<C; ++i) {
            cin >> p[i];
        }
        vector<vector<int>> q(C), r(C);
        for(int i=0; i<C; ++i) {
            q[i].resize(p[i]);
            r[i].resize(p[i]);
            for(int j=0; j<p[i]-1; ++j) {
                cin >> q[i][j];
            }
            q[i][q[i].size()-1] = INF;
            for(int j=0; j<p[i]; ++j) {
                cin >> r[i][j];
            }
        }
        vector<vector<int>> dist(N, vector<int>(C, INF));
        priority_queue<state, vector<state>, greater<state>> que;
        que.push({S, -1, 0, 0});
        while(!que.empty()) {
            state now = que.top(); que.pop();
            if(now.line != -1 && dist[now.v][now.line] < now.cost) {
                continue;
            }
            for(auto& e : g[now.v]) {
                int l = e.line;
                state next = now;
                next.v = e.to;
                next.line = l;
                if(l == now.line) {
                    next.count += e.cost;
                    int idx1 = lower_bound(q[l].begin(), q[l].end(), now.count) - q[l].begin();
                    int idx2 = lower_bound(q[l].begin(), q[l].end(), next.count) - q[l].begin();
                    if(idx1 == idx2) {
                        next.cost += r[l][idx1] * e.cost;
                    } else {
                        next.cost += r[l][idx1] * (q[l][idx1] - now.count);
                        for(int i=idx1+1; i<idx2; ++i) {
                            next.cost += r[l][i] * (q[l][i] - q[l][i-1]);
                        }
                        next.cost += r[l][idx2] * (next.count - q[l][idx2-1]);
                    }
                } else {
                    next.count = e.cost;
                    int idx = lower_bound(q[l].begin(), q[l].end(), next.count) - q[l].begin();
                    for(int i=0; i<idx; ++i) {
                        int dis = (i == 0 ? q[l][0] : q[l][i] - q[l][i-1]);
                        next.cost += r[l][i] * dis;
                    }
                    next.cost += r[l][idx] * (next.count - (idx == 0 ? 0 : q[l][idx-1]));
                }
                if(dist[next.v][next.line] > next.cost) {
                    que.push(next);
                    dist[next.v][next.line] = next.cost;
                }
            }
        }
        int res = *min_element(dist[G].begin(), dist[G].end());
        if(res == INF) {
            cout << -1 << endl;
        } else {
            cout << res << endl;
        }
    }
}


Measured memory_bytes: 8312