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

int dist[25][110][110];
int cost[110][110];
const int INF = 1e7;

int main() {
    int n, m, com, s, t;
    while (cin >> n >> m >> com >> s >> t) {
        if (n == 0) break;
        for (int i = 0; i < 25; i++) {
            for (int j = 0; j < 110; j++) {
                for (int k = 0; k < 110; k++) {
                    if (j == k) {
                        dist[i][j][k] = 0;
                    } else {
                        dist[i][j][k] = INF;
                    }
                }
            }
        }
        for (int j = 0; j < 110; j++) {
            for (int k = 0; k < 110; k++) {
                if (j == k) {
                    cost[j][k] = 0;
                } else {
                    cost[j][k] = INF;
                }
            }
        }
        vector<int> x(m), y(m), d(m), c(m);
        for (int i = 0; i < m; i++) {
            cin >> x[i] >> y[i] >> d[i] >> c[i];
            x[i]--;
            y[i]--;
            c[i]--;
            dist[c[i]][x[i]][y[i]] = min(dist[c[i]][x[i]][y[i]], d[i]);
            dist[c[i]][y[i]][x[i]] = min(dist[c[i]][y[i]][x[i]], d[i]);
        }
        vector<int> p(com);
        for (int i = 0; i < com; i++) cin >> p[i];
        vector<vector<int> > q(com), r(com);
        for (int i = 0; i < com; i++) {
            q[i] = vector<int>(p[i] - 1);
            r[i] = vector<int>(p[i]);
            for (int j = 0; j < p[i] - 1; j++) cin >> q[i][j];
            for (int j = 0; j < p[i]; j++) cin >> r[i][j];
        }
        for (int l = 0; l < com; l++) {
            for (int k = 0; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        dist[l][i][j] =
                            min(dist[l][i][j], dist[l][i][k] + dist[l][k][j]);
                    }
                }
            }
        }
        for (int l = 0; l < com; l++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    int tmp = 0;
                    for (int k = 0; k < p[l] - 1; k++) {
                        if (dist[l][i][j] < q[l][k]) {
                            tmp +=
                                (dist[l][i][j] - (k == 0 ? 0 : q[l][k - 1])) *
                                r[l][k];
                            break;
                        } else {
                            tmp += (q[l][k] - (k == 0 ? 0 : q[l][k - 1])) *
                                   r[l][k];
                        }
                    }
                    if (p[l] == 1) {
                        tmp = dist[l][i][j] * r[l][0];
                    } else if (dist[l][i][j] > q[l].back()) {
                        tmp += (dist[l][i][j] - q[l].back()) * r[l].back();
                    }
                    cost[i][j] = min(cost[i][j], tmp);
                }
            }
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                }
            }
        }
        if (cost[s - 1][t - 1] >= INF) {
            cout << -1 << endl;
        } else {
            cout << cost[s - 1][t - 1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4444