#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int fare[101][101], dist[21][101][101];
int cost[101];
int P[21];
int N, M, C, S, G;
typedef pair<int, int> pint;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N >> M >> C >> S >> G && N){
        S--; G--;
        rep(i, 21) rep(j, 101) rep(k, 101) dist[i][j][k] = INF;
        rep(i, 21) rep(j, 101) dist[i][j][j] = 0;
        rep(i, 101) rep(j, 101) fare[i][j] = INF;
        rep(i, 101) fare[i][i] = 0;
        int x_, y_, d_, c_;
        rep(i, M){
            cin >> x_ >> y_ >> d_ >> c_;
            x_--; y_--; c_--;
            dist[c_][x_][y_] = dist[c_][y_][x_] = min(dist[c_][x_][y_], d_);
        }
        rep(c, C) rep(k, N) rep(i, N) REP(j, i + 1, N)
          dist[c][j][i] = dist[c][i][j] = min(dist[c][i][j], dist[c][i][k] + dist[c][k][j]);
        rep(c, C) cin >> P[c];
        rep(c, C){
            vector<int> Q(P[c] + 1, INF), R(P[c]), f(P[c]);
            REP(i, 1, P[c]) cin >> Q[i];
            Q[0] = 0;
            rep(j, P[c]) cin >> R[j];
            f[0] = 0;
            REP(i, 1, P[c]) f[i] = R[i - 1] * (Q[i] - Q[i - 1]) + f[i - 1];
            rep(i, N - 1) REP(j, i + 1, N){
                if(dist[c][i][j] == INF) continue;
                int it = lower_bound(Q.begin(), Q.end(), dist[c][i][j]) - Q.begin();
                it--;
                int temp = f[it] + R[it] * (dist[c][i][j] - Q[it]);
                fare[i][j] = fare[j][i] = min(fare[i][j], temp);
            }
        }
        priority_queue<pint, vector<pint>, greater<pint> > que;
        fill(cost, cost + N, INF);
        cost[S] = 0;
        que.push(pint(0, S));
        while(!que.empty()){
            pint now = que.top(); que.pop();
            int v = now.second;
            if(cost[v] < now.first) continue;
            rep(i, N){
                if(fare[v][i] == INF || v == i) continue;
                if(cost[i] > cost[v] + fare[v][i]){
                    cost[i] = cost[v] + fare[v][i];
                    que.push(pint(cost[i], i));
                }
            }
        }
        int ans = cost[G];
        if(ans == INF) ans = -1;
        cout << ans << endl;
    }
    return 0;
}