#include<bits/stdc++.h>
#define mp make_pair
using namespace std;

typedef pair<int, int> pii;
struct edge{
  int to, cost;  
};
int n, m, c, s, g;
int calc(int dist, vector<pii> fare){
  if(dist == 1e9)return 1e9;
  int prev = 0, res = 0;
  for(int i = 0; i < fare.size(); i++){
    if(dist < fare[i].first){
      res += fare[i].second*(dist - prev);
      return res; 
    }
    res += fare[i].second*(fare[i].first - prev);
    prev = fare[i].first;
  }
  return res;
}

void DistToCost(vector<vector<vector<int> > > &g, vector<vector<pii> > fare_comp){
  for(int comp = 0; comp < c; comp++){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	g[comp][i][j] = calc(g[comp][i][j], fare_comp[comp]);
      }
    }
  }
}

int main(){
  while(cin >> n >> m >> c >> s >> g, n){
    s--, g--;
    //????????????????????¨?????£??\??????
    vector<vector<vector<int> > > graph(c, vector<vector<int> >(n, vector<int>(n, 0)));
    for(int i = 0; i < c; i++){
      for(int j = 0; j < n; j++){
	for(int k = 0; k < n; k++){
	  graph[i][j][k] = 1e9;
	}
      }
    }
    
    for(int i = 0; i < m; i++){
      int to, cost, from, comp;
      cin >> from >> to >> cost >> comp;
      from--, to--, comp--;
      graph[comp][from][to] = min(graph[comp][from][to], cost);
      graph[comp][to][from] = min(graph[comp][to][from], cost);
    }
    for(int comp = 0; comp < c; comp++){
      for(int i = 0; i < n; i++){
	graph[comp][i][i] = 0;
      }
      for(int k = 0; k < n; k++){
	for(int i = 0; i < n; i++){
	  for(int j = 0; j < n; j++){
	    graph[comp][i][j] = min(graph[comp][i][j], 
				    graph[comp][i][k] + graph[comp][k][j]);
	  }
	}
      }
    }
    vector<vector<pii> >fare_comp(c);//q, p
    for(int i = 0; i < c; i++){
      int p;
      cin >> p;
      fare_comp[i].resize(p);
    }

    for(int i = 0; i < c; i++){
      for(int j = 0; j < fare_comp[i].size() - 1; j++){
	cin >> fare_comp[i][j].first;
      }
      fare_comp[i][fare_comp[i].size() - 1].first = 1e9;
      for(int j = 0; j < fare_comp[i].size(); j++){
	cin >> fare_comp[i][j].second;
      }
    }
    // for(int cp = 0; cp < c; cp++){
    //   cout << "graph[" << cp << "]:" << endl;
    //   for(int i = 0; i < n; i++){
    // 	for(int j = 0; j < n; j++){
    // 	  if(graph[cp][i][j] == 1e9)cout << 0 << " ";
    // 	  else cout << graph[cp][i][j] << " ";
    // 	}
    // 	cout << endl;
    //   }
    // }
    
    DistToCost(graph, fare_comp);
    vector<vector<edge> > fare(n);
    for(int comp = 0; comp < c; comp++){
      edge e;
      for(int i = 0; i < n; i++){
	for(int j = 0; j < n; j++){
	  e.to = j, e.cost = graph[comp][i][j];
	  if(i == j || e.cost == 1e9)continue;
	  
	  fare[i].push_back(e);
	}
      }
    }
    // for(int i = 0; i < n; i++){
    //   cout << "i:" << i << endl;
    //   for(int j = 0; j < fare[i].size(); j++){
    // 	cout << fare[i][j].cost << ":" << fare[i][j].to << " ";
    //   }
    //   cout << endl;
    // }
    int dp[n];
    priority_queue<pii, vector<pii>, greater<pii> > que;
    for(int i = 0; i < n; i++)dp[i] = 1e9;
    dp[s] = 0;
    que.push(mp(0, s));
    while(que.size()){
      int cost = que.top().first;
      int v = que.top().second;
      que.pop();
      if(v == g)break;
      for(int i = 0; i < fare[v].size(); i++){
	int nv = fare[v][i].to;
	if(dp[nv] > fare[v][i].cost + cost){
	  dp[nv] = fare[v][i].cost + cost;
	  que.push(mp(dp[nv], nv));
	}
      }
    }
    if(dp[g] == 1e9)cout << -1 << endl;
    else cout << dp[g] << endl;
  }
  return 0;
}

Measured memory_bytes: 3816