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

#define INF 1e9

int min(int a, int b){ return a < b ? a : b; } 

int railcost(int c, int dist, vector<vector<pair<int, int> > > &ticket){
  if(dist == INF){ return INF; }
  
  int res = 0, nowdist = 0;
  for(int i = 0; nowdist < dist; i++){
    res += (min(ticket[c][i].first, dist) - nowdist) * ticket[c][i].second;
    nowdist = ticket[c][i].first;
  }
  
  return res;
}



int main(void){
  while(true){
    int n, m, c, s, g;
    cin >> n >> m >> c >> s >> g;
    if(n == 0 && m == 0 && c == 0 && s == 0 && g == 0){ break; }
    --s, --g;
    
    // ??????????????±??????????????? ((?????¢, ??????), ?????????)
    vector<vector<vector<int> > > adjmatrix(c, vector<vector<int> >(n, vector<int>(n, INF)));
    int xi, yi, di, ci;
    for(int i = 0; i < m; i++){
      cin >> xi >> yi >> di >> ci;
      --xi, --yi; --ci;
      adjmatrix[ci][xi][yi] = adjmatrix[ci][yi][xi] = min(adjmatrix[ci][xi][yi], di);
    }
    for(int h = 0; h < c; h++)
      for(int i = 0; i < n; i++)
        adjmatrix[h][i][i] = 0;

    // ???????????°??????????????±???????????????
    vector<int> p(c);
    vector<vector<pair<int, int> > > ticket(c);
    for(int i = 0; i < c; i++){ cin >> p[i]; }
    for(int i = 0; i < c; i++){
      vector<int> q(p[i]), r(p[i]);
      for(int j = 0; j < p[i] - 1; j++){ cin >> q[j]; }
      q[p[i] - 1] = INF;
      for(int j = 0; j < p[i]; j++){ cin >> r[j]; }
      for(int j = 0; j < p[i]; j++){ ticket[i].push_back(make_pair(q[j], r[j])); }
    }

    // ???????????¨??????????????£?????????????????????
    for(int h = 0; h < c; h++)
      for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++)
          for(int j = 0; j < n; j++)
            adjmatrix[h][i][j] = min(adjmatrix[h][i][j], adjmatrix[h][i][k] + adjmatrix[h][k][j]);
    
    // ???????????£??????????????????????????¢????????????????????????????????????
    for(int h = 0; h < c; h++)
      for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
          adjmatrix[h][i][j] = railcost(h, adjmatrix[h][i][j], ticket);

    
    // ????????§???????????????????????§?????????????????¨????????´??\????????????????????¨??????????????§???
    // ???????????§????°???????????????????????????§??£??\???????????¨??????
    vector<vector<pair<int, int> > > adjlist(n);
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        long long int min = INF;
        for(int h = 0; h < c; h++){
          if(min > adjmatrix[h][i][j]){ min = adjmatrix[h][i][j]; }
        }
        if(min != INF){ adjlist[i].push_back(make_pair(min, j)); }
      }
    }

    
    // ?????£?????£??\???????????§????????????????????????
    priority_queue<pair<int, int> > wait;
    vector<int> result(n, INF);

    result[s] = 0;
    wait.push(make_pair(0, s));

    // ????????????????????¬???
    while(!wait.empty()){
      int nowpoint = (wait.top()).second;
      int nowcost = -(wait.top()).first;
      wait.pop();
      if(result[nowpoint] < nowcost){ continue; }

      for(int i = 0; i < adjlist[nowpoint].size(); i++){
        int nextpoint = adjlist[nowpoint][i].second;
        int nextcost = adjlist[nowpoint][i].first + nowcost;
        if(result[nextpoint] > nextcost){
          result[nextpoint] = nextcost;
          wait.push(make_pair(-nextcost, nextpoint));
        }
      }
    }

    // ???????????????
    if(result[g] == INF){ cout << -1 << endl; }
    else{ cout << result[g] << endl; }    
  }
  
  return 0;
}

Measured memory_bytes: 2284