#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <class T>
using Matrix = Vector<Vector<T>>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

Bool solve() {
    Int n, m, l, s, g;
    std::cin >> n >> m >> l >> s >> g;
    if (n == 0) return false;
    --s, --g;

    Vector<Matrix<Int>> graphs(l, Matrix<Int>(n, Vector<Int>(n, INF)));
    for (Int i = 0; i < m; ++i) {
        Int u, v, d, c;
        std::cin >> u >> v >> d >> c;
        --u, --v, --c;
        graphs[c][u][v] = std::min(graphs[c][u][v], d);
        graphs[c][v][u] = std::min(graphs[c][v][u], d);
    }

    Vector<Int> p(l);
    for (auto& x : p) std::cin >> x;

    Vector<Vector<Int>> q(l), r(l);
    for (Int c = 0; c < l; ++c) {
        q[c].resize(p[c] - 1);
        for (auto& x : q[c]) std::cin >> x;
        q[c].push_back(INF);
        r[c].resize(p[c]);
        for (auto& x : r[c]) std::cin >> x;
    }

    Matrix<Int> graph(n, Vector<Int>(n, INF));
    for (Int i = 0; i < n; ++i) graph[i][i] = 0;

    for (Int c = 0; c < l; ++c) {
        auto& g = graphs[c];

        for (Int j = 0; j < n; ++j) {
            for (Int i = 0; i < n; ++i) {
                for (Int k = 0; k < n; ++k) {
                    g[i][k] = std::min(g[i][k], g[i][j] + g[j][k]);
                }
            }
        }

        for (Int i = 0; i < n; ++i) {
            for (Int j = 0; j < n; ++j) {
                if (g[i][j] == INF) continue;

                Int cost = 0, prev = 0;
                for (Int k = 0; k < p[c]; ++k) {
                    if (g[i][j] > q[c][k]) {
                        cost += (q[c][k] - prev) * r[c][k];
                        prev = q[c][k];
                    } else {
                        cost += (g[i][j] - prev) * r[c][k];
                        break;
                    }
                }
                graph[i][j] = std::min(graph[i][j], cost);
            }
        }
    }

    for (Int j = 0; j < n; ++j) {
        for (Int i = 0; i < n; ++i) {
            for (Int k = 0; k < n; ++k) {
                graph[i][k] = std::min(graph[i][k], graph[i][j] + graph[j][k]);
            }
        }
    }

    std::cout << (graph[s][g] == INF ? -1 : graph[s][g]) << std::endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 4764