#include <bits/stdc++.h>

using namespace std;

using pii = pair<long long, long long>;
using ll = long long;

const ll LINF = 1LL << 60;

struct edge
{
    ll to, cost, inc;
    edge(int t, ll d, ll c) : to(t), cost(d), inc(c) {}
};

void dijkstra(int s, vector<ll> &dist, vector<vector<edge>> &G)
{
    fill(dist.begin(), dist.end(), LINF);
    dist[s] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.push(make_pair(0, s));
    while (!que.empty())
    {
        auto p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first)
            continue;
        for (auto e : G[v])
        {
            if (dist[e.to] > dist[v] + e.cost)
            {
                dist[e.to] = dist[v] + e.cost;
                que.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

void dijkstra2(int s, int inc, vector<ll> &dist, vector<vector<edge>> &G)
{
    fill(dist.begin(), dist.end(), LINF);
    dist[s] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.push(make_pair(0, s));
    while (!que.empty())
    {
        auto p = que.top();
        que.pop();
        int v = p.second;
        if (dist[v] < p.first)
            continue;
        for (auto e : G[v])
        {
            if (e.inc != inc)
                continue;
            if (dist[e.to] > dist[v] + e.cost)
            {
                dist[e.to] = dist[v] + e.cost;
                que.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

int main()
{
    int N, M, C, s, g;
    while (cin >> N >> M >> C >> s >> g, N | M | C | s | g)
    {
        s--, g--;
        vector<vector<edge>> G(N, vector<edge>());
        for (int i = 0; i < M; i++)
        {
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            x--, y--;
            c--;
            G[x].push_back(edge(y, d, c));
            G[y].push_back(edge(x, d, c));
        }
        vector<vector<ll>> table(C, vector<ll>(20010));
        vector<ll> p(C);
        for (int i = 0; i < C; i++)
            cin >> p[i];
        for (int i = 0; i < C; i++)
        {
            vector<ll> q(p[i] - 1);
            for (int j = 0; j < p[i] - 1; j++)
            {
                cin >> q[j];
            }
            vector<ll> r(p[i]);
            for (int j = 0; j < p[i]; j++)
            {
                cin >> r[j];
            }
            int now = 0;
            q.push_back(LINF);
            for (int j = 1; j < 20010; j++)
            {
                if (j <= q[now])
                {
                    table[i][j] = table[i][j - 1] + r[now];
                }
                else
                {
                    now++;
                    table[i][j] = table[i][j - 1] + r[now];
                }
            }
        }
        vector<vector<edge>> G2(N, vector<edge>());
        for (int i = 0; i < N; i++)
        {
            for (int c = 0; c < C; c++)
            {
                vector<ll> dist(N);
                dijkstra2(i, c, dist, G);
                for (int j = 0; j < N; j++)
                {
                    if (dist[j] != LINF && dist[j] != 0)
                    {
                        G2[i].push_back(edge(j, table[c][dist[j]], 0));
                    }
                }
            }
        }
        vector<ll> dist(N);
        dijkstra(s, dist, G2);
        if (dist[g] == LINF)
        {
            cout << -1 << endl;
        }
        else
        {
            cout << dist[g] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 11256