#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;


int main(void) {
    int n, m, com, s, g;
    while(cin >> n >> m >> com >> s >> g, n){
        s--,g--;
        vi x(m),y(m),d(m),c(m);
        rep(i,m){
            cin >> x[i] >> y[i] >> d[i] >> c[i];
            x[i]--,y[i]--,c[i]--;
        }


        int dp[100][100];
        rep(i,100)rep(j,100)dp[i][j] = INF;
        rep(i,100)dp[i][i] = 0;

        vi p(com);
        rep(i,com) cin >> p[i];
        rep(i,com){
            //cout << i << endl;
            vi q(p[i]-1),r(p[i]);
            rep(j,p[i]-1)cin >> q[j];
            rep(j,p[i])cin >> r[j];
            q.push_back(100*200);

            int cost[100*200+5];
            cost[0] = 0;
            int ind = 0;
            loop(j,1,100*200+5){
                if(j>q[ind])ind++;
                cost[j] = cost[j-1] + r[ind];
            }


            int v[100][100];
            rep(j,100)rep(k,100)v[j][k] = INF;
            rep(j,100)v[j][j]=0;

            rep(a,m)if(c[a] == i){
                v[x[a]][y[a]] = v[y[a]][x[a]] = min(v[x[a]][y[a]],d[a]);
            }

            rep(k,n)rep(ii,n)rep(jj,n){
                v[ii][jj] = min(v[ii][jj], v[ii][k]+v[k][jj]);
            }

            rep(ii,n)rep(jj,n)if(v[ii][jj]<INF){
                dp[ii][jj] = min(dp[ii][jj],cost[v[ii][jj]]);
            //    cout << ii << " " << jj << " cost=" << cost[v[ii][jj]]<<endl;
            }

        }


        //rep(i,n)rep(j,n)cout << i <<" " << j << " " << dp[i][j] << endl;

        rep(k,n)rep(i,n)rep(j,n){
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
        }
        if(dp[s][g] == INF)dp[s][g] = -1;
        cout << dp[s][g] << endl;
    }
}

