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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename M>
std::vector<std::vector<typename M::T>> warshall_floyd(const std::vector<std::vector<typename M::T>> &graph) {
    using T = typename M::T;
    int n = graph.size();
    std::vector<std::vector<T>> ret(graph);
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                T dist = M::op(ret[i][k], ret[k][j]);
                if (M::gr(ret[i][j], dist)) { ret[i][j] = dist; }
            }
        }
    }
    return ret;
}

struct int_wf {
    using T = int;
    static T ab() { return std::numeric_limits<T>::max(); }
    static T op(const T &a, const T &b) { return a == ab() || b == ab() ? ab() : a + b; }
    static bool gr(const T &a, const T &b) { return a > b; }
};

int p[22], q[22][55], r[22][55], rcc[22][55];
int cost(int c, int d) {
    if (d == int_wf::ab()) { return d; }
    int idx = upper_bound(q[c], q[c] + p[c], d) - q[c] - 1;
    return rcc[c][idx] + r[c][idx] * (d - q[c][idx]);
}

signed main() {
    while (true) {
        int n, m, c, s, g;
        cin >> n >> m >> c >> s >> g;
        s--, g--;
        if (n == 0) { break; }
        vector<vvint> comps(c, vvint(n, vint(n, int_wf::ab())));
        rep(i, c) {
            rep(j, n) { comps[i][j][j] = 0; }
        }
        rep(i, m) {
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            x--, y--, c--;
            chmin(comps[c][x][y], d);
            chmin(comps[c][y][x], d);
        }
        rep(i, c) { comps[i] = warshall_floyd<int_wf>(comps[i]); }
        rep(i, c) { cin >> p[i]; }
        rep(i, c) {
            reps(j, p[i] - 1) { cin >> q[i][j]; }
            q[i][p[i]] = LLONG_MAX;
            rep(j, p[i]) { cin >> r[i][j]; }
            rep(j, p[i] - 1) { rcc[i][j + 1] = rcc[i][j] + r[i][j] * (q[i][j + 1] - q[i][j]); }
        }
        vvint last(n, vint(n, int_wf::ab()));
        rep(i, c) {
            rep(j, n)rep(k, n) { chmin(last[j][k], cost(i, comps[i][j][k])); }
        }
        last = warshall_floyd<int_wf>(last);
        cout << (last[s][g] == int_wf::ab() ? -1 : last[s][g]) << endl;
    }
}


Measured memory_bytes: 4820