#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)

int n,m,c,s,g;
int p[30], q[30][60], r[30][60];

int d_dist[30][110][110];
int d_final[110][110];

const int inf = 1e9;

inline int getcost(int dist, int *q, int *p){
    if(dist == inf) return inf;
    int res = 0;
    rep(i,1000000){
        if(dist <= q[i+1]){
            res += (dist-q[i]) * p[i];
            break;
        } else {
            res += (q[i+1]-q[i]) * p[i];
        }
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*
      ????´?????????¢??§???????????¨???WF 1
      ??????????????¨???????????¨????????? 2
      ??????????????§WF 3
     */
    while(cin >> n >> m >> c >> s >> g && n){
        --s, --g;
        rep(ic,c)rep(i,n)rep(j,n) d_dist[ic][i][j] = inf;
        rep(i,n)rep(j,n) d_final[i][j] = inf;
        rep(i,c)rep(j,n) d_dist[i][j][j] = 0;
        rep(i,n) d_final[i][i] = 0;

        rep(i,m){
            int x,y,d,c;
            cin >> x >> y >> d >> c;
            --x, --y, --c;
            d_dist[c][x][y] = min(d_dist[c][x][y], d);
            d_dist[c][y][x] = min(d_dist[c][y][x], d);
        }

        rep(i,c) cin >> p[i];
        rep(i,c){
            q[i][0] = 0;
            rep(j,p[i]-1) cin >> q[i][j+1];
            q[i][p[i]] = inf*2;
            rep(j,p[i]) cin >> r[i][j];
        }

        rep(ic,c) rep(k,n)rep(i,n)rep(j,n) {
            d_dist[ic][i][j] = min(d_dist[ic][i][j], d_dist[ic][i][k] + d_dist[ic][k][j]);
        }

        rep(ic,c)rep(i,n)rep(j,n){
            d_final[i][j] = min(d_final[i][j], getcost(d_dist[ic][i][j], q[ic], r[ic]));
        }

        rep(k,n)rep(i,n)rep(j,n){
            d_final[i][j] = min(d_final[i][j], d_final[i][k] + d_final[k][j]);
        }
        int ans = d_final[s][g];
        cout << (ans == inf ? -1 : ans) << '\n';
    }
}