#include <iostream>
#include <vector>
using namespace std;

int main(){
  const long long INF = 1e9;
  int N, M, C, S, G;
  while(cin >> N >> M >> C >> S >> G, N){
    --S,--G;
    vector<vector<vector<long long>>> D(C,vector<vector<long long>>(N,vector<long long>(N,INF)));
    for(int i = 0; i < M; ++i){
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      --x,--y,--c;
      D[c][x][y] = min<long long>(D[c][x][y],d);
      D[c][y][x] = min<long long>(D[c][y][x],d);
    }

    for(auto &d : D){
      for(int i = 0; i < N; ++i) d[i][i] = 0;
      for(int k = 0; k < N; ++k)
        for(int i = 0; i < N; ++i)
          for(int j = 0; j < N; ++j)
            d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }
    
    vector<long long> P(C);
    for(int i = 0; i < C; ++i) cin >> P[i];

    vector<vector<long long>> E(N,vector<long long>(N,INF));
    for(int i = 0; i < C; ++i){
      vector<long long> Q(P[i]+1), R(P[i]+1);
      for(int j = 0; j+1 < P[i]; ++j) cin >> Q[j+1];
      Q.back() = INF;
      for(int j = 0; j < P[i]; ++j) cin >> R[j+1];
      vector<long long> T(P[i]+1);
      for(int j = 1; j <= P[i]; ++j){
        T[j] += T[j-1];
        T[j] += (Q[j]-Q[j-1])*R[j];
      }
      for(int j = 0; j < N; ++j){
        for(int k = 0; k < N; ++k){
          if(j == k) continue;
          int d = D[i][j][k];
          if(d >= INF) continue;
          int idx = lower_bound(Q.begin(), Q.end(), d) - Q.begin();
          long long cost = (d-Q[idx-1])*R[idx] + T[idx-1];
          E[j][k] = min(E[j][k],cost);
        }
      }
    }
    for(int i = 0; i < N; ++i) E[i][i] = 0;

    for(int k = 0; k < N; ++k)
      for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j)
          E[i][j] = min(E[i][j],E[i][k]+E[k][j]);
    int ans = E[S][G];
    if(ans >= INF) ans = -1;
    cout << ans << endl;
  }
}

