#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

#define DUMPOUT cerr
#define dump(...) DUMPOUT << "  " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__<< "]\n -> "; dump_func(__VA_ARGS__);
template <class T, class U> ostream& operator << (ostream& os, const pair<T, U>& obj) { os << "<" << obj.first << ", " << obj.second << ">"; return os; }
template <typename T> ostream& operator << (ostream& os, vector<T>& vec) { os << "["; for (int i = 0; i < vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "]"; return os; }
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head&& head, Tail&&... tail) { DUMPOUT << head << (sizeof...(Tail) == 0 ? " " : ", "); dump_func(move(tail)...); }
// =======================

//---------------------------------------------------------------
// ------ graph ------ //
using Weight = int;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
struct Graph {
    vector<Edges> adj;
    Graph(int n) : adj(n) { }
    int size() { return adj.size(); }
    Edges operator [] (int v) { return adj[v]; }
    void add_edge(int a, int b, Weight w = 1) { // graph
        adj[a].emplace_back(a, b, w);
        adj[b].emplace_back(b, a, w);
    }
    void add_arc(int a, int b, Weight w = 1) {  // digraph
        adj[a].emplace_back(a, b, w);
    }
};
using Array = vector<Weight>;
using Matrix = vector<Array>;

// ------ WarshallFloyd ------ //
void WarshallFloyd(Matrix &d) {
    int n = d.size();
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
            if (d[i][k] != INF && d[k][j] != INF) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}
//---------------------------------------------------------------

int main() {
    int N, M, C, s, g;  // 駅の数, 路線の数, 鉄道会社の数, 出発地の駅番号, 目的地の駅番号
    while (cin >> N >> M >> C >> s >> g, s--, g--, N) {
        vector<Matrix> dist(C, Matrix(N, Array(N, INF)));
        for (int k = 0; k < C; k++) for (int i = 0; i < N; i++) dist[k][i][i] = 0;
        for (int i = 0; i < M; i++) {   // m 本の路線
            int x, y, d, c; cin >> x >> y >> d >> c; x--; y--; c--;
            // x <-> y, d: 路線の長さ, c: 路線を運営する鉄道会社の番号
            dist[c][x][y] = dist[c][y][x] = min(dist[c][x][y], d);
        }
        // 各鉄道会社の運賃表（距離と運賃の関係）は折れ線グラフ
        vector<int> p(C);   // 折れ線の区間の数
        for (int k = 0; k < C; k++) cin >> p[k];
        vector<vector<int>> q(C);   // 折れ目の位置を示す距離の値
        vector<vector<int>> r(C);   // 該当する距離の範囲に対して距離 1 当たりの運賃の増分
        vector<vector<int>> dist2cost(C);
        for (int k = 0; k < C; k++) {
            q[k].assign(p[k] + 1, 0); q[k][p[k]] = 20000;
            r[k].assign(p[k] + 1, 0);
            for (int i = 1; i < p[k]; i++) cin >> q[k][i];
            for (int i = 1; i <= p[k]; i++) cin >> r[k][i];
            dist2cost[k].assign(20001, 0);
            for (int i = 1; i <= p[k]; i++) {
                for (int j = q[k][i - 1] + 1; j <= q[k][i]; j++) {
                    dist2cost[k][j] += dist2cost[k][j - 1] + r[k][i];
                }
            }
        }
        // 各鉄道会社毎に APSP
        for (int k = 0; k < C; k++) WarshallFloyd(dist[k]);
        // 各鉄道会社の情報をコストでまとめる
        Matrix cost(N, Array(N, INF));
        for (int i = 0; i < N; i++) cost[i][i] = 0;
        for (int k = 0; k < C; k++) {
            for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
                if (dist[k][i][j] == INF) continue;
                cost[i][j] = min(cost[i][j], dist2cost[k][dist[k][i][j]]);
            }
        }
        // SSSP
        WarshallFloyd(cost);
        cout << (cost[s][g] == INF ? -1 : cost[s][g]) << endl;
    }
    return 0;
}


Measured memory_bytes: 5256