//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr long long INF = 1000000000000000LL;

long long getCost(vector<long long> &q, vector<long long> &r, long long dis) {
    long long cost = 0;
    for (int i = 0; i < q.size() - 1; i++) {
        long long t = min(q[i + 1] - q[i], dis);
        cost += t * r[i];
        dis -= t;
    }
    cost += dis * r.back();
    return cost;
}

int main() {

    int count = 0;

    while (true) {

        long long N, M, C, s, g;
        cin >> N >> M >> C >> s >> g;

        count++;

        if (!(N | M | C | s | g)) break;
        s--, g--;


        auto distG = vector<vector<vector<long long>>>(C, vector<vector<long long>>(N, vector<long long>(N, INF)));
        auto costG = vector<vector<vector<long long>>>(C, vector<vector<long long>>(N, vector<long long>(N, INF)));
        auto ansG = vector<vector<long long>>(N, vector<long long>(N, INF));

        for (long long i = 0; i < M; i++) {
            long long x, y, d, c;
            cin >> x >> y >> d >> c;
            x--, y--, c--;
            distG[c][x][y] = min(d, distG[c][x][y]);
            distG[c][y][x] = min(d, distG[c][y][x]);
        }
        for (long long i = 0; i < C; i++) for (long long j = 0; j < N; j++) distG[i][j][j] = 0;
        for (long long i = 0; i < C; i++) for (long long j = 0; j < N; j++) costG[i][j][j] = 0;
        for (long long i = 0; i < N; i++) ansG[i][i] = 0;

        //距離を求める
        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++)
                        distG[l][i][j] = min(distG[l][i][j], distG[l][i][k] + distG[l][k][j]);

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

        for (int i = 0; i < C; i++) {
            vector<long long> q(p[i], 0);
            for (int j = 1; j < p[i]; j++) cin >> q[j];

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

            for (int j = 0; j < N; j++) for (int k = 0; k < N; k++) if (distG[i][j][k] < INF) costG[i][j][k] = getCost(q, r, distG[i][j][k]);
        }

        for (int i = 0; i < C; i++)for (int j = 0; j < N; j++) for (int k = 0; k < N; k++) ansG[j][k] = min(ansG[j][k], costG[i][j][k]);

        for (int k = 0; k < N; k++)
            for (int i = 0; i < N; i++)
                for (int j = 0; j < N; j++)
                    ansG[i][j] = min(ansG[i][j], ansG[i][k] + ansG[k][j]);

        long long ans = ansG[s][g];
        if (ans == INF) cout << -1 << endl;
        else cout << ans << endl;

    }

}














































Measured memory_bytes: 6404