// ?????? railway connection
#include <iostream>
#define INF 1001000000
#define MAX 10010
#define N 150
#define rep(i,p) for(int i=0;i<p;i++)
using namespace std;
int n,m,c,s,g,x,y,d,cc;
int X[MAX];
int Y[MAX];
int D[MAX];
int C[MAX];
int p[N];
int q[N][N];
int r[N][N];
// all_dist[c][x][y] : c????????????x->y????????¢
int all_dist[N][N][N];
// c????????????x->y?????????
int all_fare[N][N][N];
// ????????????c??????????????¢??????????????????memo
int how_much[2500000];
// s ?????????????????????
int ans[120];

int dist_to_fare (int dist , int company) {
  if (dist == 0) return 0;
  if (dist == INF) return INF;
  if (how_much[dist] != 0) return how_much[dist];
  int fare = 0;
  int k = 0;
  for (;k<p[company]-1;k++) 
    if (dist < q[company][k]) break;
  rep(i,k) {
    if (i == 0) fare += q[company][i]*r[company][i];
    else fare += (q[company][i]-q[company][i-1])*r[company][i];
  }
  fare += (dist-q[company][k-1])*r[company][k];
  how_much[dist] = fare;
  return fare;
}
int main(){
  while (1) {
    // n : ?§??????°
    // m : ???????????°
    // c : ?????????????????°
    // s : ????????°
    // g : ????????°
    cin >> n >> m >> c >> s >> g;
    if (!n and !m and !c and !s and !g) break;
    // ????????????0???????????????
    s--;
    g--;
    rep(i,m) {
      // root : x <--> y
      // d    : distance
      // c    : company
      // ????????????????§?????????¶?????????2??¬??\????????¨???????????¨???????????????
      cin >> x >> y >> D[i] >> cc;
      // ????????????0???????????????
      X[i] = x-1;
      Y[i] = y-1;
      C[i] = cc-1;
    }
    rep(i,c) cin >> p[i];
    rep(i,c) {
      rep(j,p[i]-1) cin >> q[i][j];
      rep(k,p[i]) cin >> r[i][k];
    }
    // ?????????????????????,??????????????????????????´??????
    // ??¨?§????????????¢????????????????±???????(??°????????°???????????§??????)
    // Bellman-Ford
    rep(i,N)rep(j,N)rep(k,N) all_dist[i][j][k] = INF; // ?????????
    rep(company,c)
      rep(start,n) {
        all_dist[company][start][start] = 0;
        rep(i,n) {
          bool update = false;
          rep(j,m){
            if (C[j] != company) continue;
            x = X[j];
            y = Y[j];
            d = D[j];
            if (all_dist[company][start][y] > all_dist[company][start][x]+d) {
              all_dist[company][start][y] = all_dist[company][start][x]+d;
              update = true;
            }
            if (all_dist[company][start][x] > all_dist[company][start][y]+d) {
              all_dist[company][start][x] = all_dist[company][start][y]+d;
              update = true;
            }
          }
          if (!update) break;
        }
      }
    // ?±????????????¢????????????????????????
    rep(company,c) {
      rep(i,2500000) how_much[i] = 0;
      rep(from,n) rep(to,n)
        all_fare[company][from][to] = dist_to_fare(all_dist[company][from][to],company);
    }
    // ?§?to?§????????????°????????§???????????¢??????????§£???
    // all_fare[c][x][y] : ??°??????
    // ans[now]          : minimum fare from s to now
    rep(i,n) ans[i] = INF;
    ans[s] = 0;
    rep(nulnul,n)
      rep(i,n)
        rep(j,n)
          rep(company,c) {
            ans[j] = min(ans[j],ans[i]+all_fare[company][i][j]);
            ans[i] = min(ans[i],ans[j]+all_fare[company][j][i]);
          }
    
    // cout << "from " << s << " to " << g << endl;
    if (ans[g] == INF) cout << -1 << endl;
    else cout << ans[g] << endl;
    // rep(i,c) {
    //   rep(j,n) {
    //     rep(k,n) cout << all_dist[i][j][k] << " ";
    //     cout << endl;
    //   }
    //   cout << endl;
    // }
    // rep(i,c) {
    //   rep(j,n) {
    //     rep(k,n) cout << all_fare[i][j][k] << " ";
    //     cout << endl;
    //   }
    //   cout << endl;
    // }

  }
  return 0;
}

Measured memory_bytes: 27240