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

int edge_dist[25][110][110];
const int INF = 1e9;
typedef pair<int,int> pii;

struct edge {
	int to, cost;
	edge(int t, int c) {
		to = t;
		cost = c;
	}
};

struct status {
	int amt;
	int vert;
	status(int a, int v) {
		amt = a;
		vert = v;
	}
};

bool operator<(const status &a, const status &b) {
	return a.amt > b.amt;
}

int main() {
	int n, m, s, c, g;
	while(cin >> n >> m >> c >> s >> g, n || m || s || c || g) {
		//cout << n << " " << m << " " << s << " " << c << " " << g << endl;
		vector<vector<edge> > edge_cost;
		vector<int> hoge;
		vector<vector<pii> > dist2cost;
		vector<int> P, Q, R;
		s--; g--;


		for(int i = 0; i < 25; i++) {
			for(int j = 0; j < 110; j++) {
				for(int k = 0; k < 110; k++) {
					edge_dist[i][j][k] = INF;
				}
				edge_dist[i][j][j] = 0;
			}
		}

		for(int i = 0; i < m; i++) {
			int x, y, d, compa;
			cin >> x >> y >> d >> compa;
			//cout << x << " " << y << " " << d << " " << compa << endl;
			x--; y--;
			compa--;
			edge_dist[compa][x][y] = edge_dist[compa][y][x] = min(d, edge_dist[compa][y][x]);
		}
		for(int i = 0; i < c; i++) {
			int tmp;
			cin >> tmp;
			//cout << tmp << " ";
			P.push_back(tmp);
		}
		//cout << endl;
		dist2cost.resize(c);
		for(int i = 0; i < c; i++) {
			dist2cost[i].resize(P[i]+1);
			dist2cost[i][0].first = 0;
			for(int j = 0; j < P[i]-1; j++) {
				cin >> dist2cost[i][j+1].first;
				//cout << dist2cost[i][j+1].first << " ";
			}
			dist2cost[i].back().first = INF;
			//cout << endl;
			
			dist2cost[i][0].second = 0;
			for(int j = 0; j < P[i]; j++) {
				cin >> dist2cost[i][j+1].second;
				//cout << dist2cost[i][j+1].second << " ";
			}
			//cout << endl;

			sort(dist2cost[i].begin(), dist2cost[i].end());
		}

		for(int i = 0; i < 25; i++) {
			for(int j = 0; j < 110; j++) {
				for(int k = 0; k < 110; k++) {
					for(int l = 0; l < 110; l++) {
						edge_dist[i][k][l] = min(edge_dist[i][k][l], edge_dist[i][k][j] + edge_dist[i][j][l]);
					}
				}
			}
		}

		edge_cost.resize(n);
		for(int i = 0; i < 25; i++) {
			for(int j = 0; j < 110; j++) {
				for(int k = 0; k < 110; k++) {
					if(j != k && edge_dist[i][j][k] != INF) {
						int dist = edge_dist[i][j][k];
						int pb = 0;
						for(int l = 1; l < dist2cost[i].size(); l++) {
							if(dist2cost[i][l].first <= dist) {
								pb += dist2cost[i][l].second * (dist2cost[i][l].first - dist2cost[i][l - 1].first);
							}
							else {
								pb += dist2cost[i][l].second * (dist - dist2cost[i][l-1].first);
								break;
							}
						}
//						cout << i << "," << dist << "," << pb << endl;;
						edge_cost[j].push_back(edge(k,pb));
					}
				}
			}
		}

		priority_queue<status> q;
		q.push(status(0, s));
		hoge.resize(n);
		int res = -1;
		for(int i = 0; i < hoge.size(); i++)
			hoge[i] = -1;
		while(!q.empty()) {
			status cur = q.top();
			q.pop();
			if(cur.vert == g) {
				res = cur.amt;
				break;
			}
			if(hoge[cur.vert] == -1) {
				hoge[cur.vert] = cur.amt;
			}
			else {
				continue;
			}
			for(int i = 0; i < edge_cost[cur.vert].size(); i++) {
				if(hoge[edge_cost[cur.vert][i].to] == -1) {
					q.push(status(cur.amt + edge_cost[cur.vert][i].cost, edge_cost[cur.vert][i].to));
				}
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 5436