#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<int> > fare(n, vector<int>(n, 1e9));
    for(int comp = 0; comp < c; comp++){
      for(int i = 0; i < n; i++){
	for(int j = 0; j < n; j++){
	  if(i == j || graph[comp][i][j] == 1e9)continue;
	  fare[i][j] = min(fare[i][j], graph[comp][i][j]);
	}
      }
    }
    // 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++){
	if(i == v)continue;
	int nc = fare[v][i];
	if(dp[i] > nc + cost){
	  dp[i] = nc + cost;
	  que.push(mp(dp[i], i));
	}
      }
    }
    if(dp[g] == 1e9)cout << -1 << endl;
    else cout << dp[g] << endl;
  }
  return 0;
}

Measured memory_bytes: 2224