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

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b-1);i>=a;i--)
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;

template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr int INF = 1e9;
void solve(int N, int M, int C, int S, int G){
    S--, G--;
    map<tuple<int, int, int>, int> E;
    rep(i, 0, M) {
        int x, y, d, c;
        cin >> x >> y >> d >> c;
        x--, y--; c--;
        if (x > y) swap(x, y);

        auto tpl = make_tuple(x, y, c);
        if (E.find(tpl) == E.end()) {
            E[tpl] = d;
        } else {
            chmin(E[tpl], d);
        }
    }
    vector<int> P(C);
    rep(i, 0, C) {
        cin >> P[i];
    }
    vector<vector<int>> Q(C), R(C);
    rep(i, 0, C) {
        vi q(P[i]), r(P[i]);
        rep(j, 0, P[i] - 1) {
            cin >> q[j];
        }
        q.back() = INF;
        rep(j, 0, P[i]) {
            cin >> r[j];
        }
        Q[i] = q;
        R[i] = r;
        
        // cerr << "Q[i] : ";
        // for (int x : Q[i]) {
        //     cerr << x << " ";
        // }
        // cerr << endl;
        // cerr << "R[i] : ";
        // for (int x : R[i]) {
        //     cerr << x << " ";
        // }
        // cerr << endl;
    }


    vector<vector<pair<int, pii>>> g(N);
    vector<vvi> warshall(C, vvi(N, vi(N, INF)));
    rep(i, 0, C) rep(j, 0, N) warshall[i][j][j] = 0;
    for (auto p : E) {
        int x, y, c;
        tie(x, y, c) = p.first;
        int d = p.second;
        g[x].push_back({y, {d, c}});
        g[y].push_back({x, {d, c}});
        warshall[c][x][y] = warshall[c][y][x] = d;
    }
    rep(c, 0, C) {
        rep(k, 0, N) {
            rep(i, 0, N) {
                rep(j, 0, N) {
                    warshall[c][i][j] = min(warshall[c][i][j], warshall[c][i][k] + warshall[c][k][j]);
                }
            }
        }
    }

    // cerr << "---- warshall ----" << endl;
    // rep(i, 0, N) {
    //     rep(j, 0, N) {
    //         cerr << warshall[0][i][j] << " ";
    //     }
    //     cerr << endl;
    // }
    // cerr << "---------" << endl;
    // rep(i, 0, N) {
    //     rep(j, 0, N) {
    //         cerr << warshall[1][i][j] << " ";
    //     }
    //     cerr << endl;
    // }

    auto f = [&](int c, int d) {
        int ret = 0;
        rep(i, 0, P[c]) {
            int prv = (i > 0 ? Q[c][i - 1] : 0);
            if (d <= Q[c][i]) {
                // cerr << "i = " << i << ", Q[c][i] = " << Q[c][i] << ", R[c][i]" << R[c][i] << endl;;
                ret += (d - prv) * R[c][i];
                break;
            } else {
                ret += (Q[c][i] - prv) * R[c][i];
            }
        }
        // cerr << "f:  c=" << c << ", d=" << d << ", ret = " << ret << endl;
        return ret;
    };

    using state = tuple<int, int, int>;
    priority_queue<pair<int, state>, vector<pair<int, state>>, greater<pair<int, state>>> q;
    vector<vector<vector<int>>> cost(N, vector<vector<int>>(N, vector<int>(C, INF)));
    for (auto e : g[S]) {
        int d, c;
        tie(d, c) = e.second;
        if (chmin(cost[S][S][c], 0LL)) {
            q.push({0, make_tuple(S, S, c)});
        }
    }
    while (q.size()) {
        int cst = q.top().first;
        int v, vp, c;
        tie(v, vp, c) = q.top().second; q.pop();
        if (cst > cost[v][vp][c]) continue;

        // cerr << "v: " << v << ", vp: " << vp << ", c: " << c << ", cst : " << cst << endl;

        for (auto e : g[v]) {
            int w, d, cc;
            w = e.first;
            tie(d, cc) = e.second;
            int next_cost;
            if (cc == c) {
                next_cost = cst - f(c, warshall[c][v][vp]) + f(c, warshall[c][w][vp]);
                if (chmin(cost[w][vp][cc], next_cost)) {
                    q.emplace(cost[w][vp][cc], make_tuple(w, vp, cc));
                } else {
                    // cerr << "skipped: w: " << w << ", cc: " << cc << endl;
                }
            } else {
                next_cost = cst + f(cc, d);
                if (chmin(cost[w][v][cc], next_cost)) {
                    q.emplace(cost[w][v][cc], make_tuple(w, v, cc));
                } else {
                    // cerr << "skipped: w: " << w << ", cc: " << cc << endl;
                }
            }
        }
    }

    int ans = INF;
    rep(vp, 0, N) {
        rep(c, 0, C) {
            chmin(ans, cost[G][vp][c]);
        }
    }
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}
signed main() {
    while (1) {
        int N,M,C,S,G;
        cin>>N>>M>>C>>S>>G;
        if (N == 0) {
            break;
        }
        solve(N,M,C,S,G);
    }
}




Measured memory_bytes: 10296