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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define minit(a, b) memset(a, b, sizeof(a))
#define size_of(a) (int)(a).size()

typedef long long lint;

struct Edge {
	int to; lint dst;
	Edge (int to_, lint dst_) : to(to_), dst(dst_) {}
	bool operator > (const Edge& e) const { return dst > e.dst; }
};

void minUpdate(lint& a, lint b) { a = min(a, b); }

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;

int n, m, c, s, g;
int p[22], q[22][55], r[22][55];
vector< vector< Edge > > edges;

lint cost[22][111][111], dist[22][111][111], price[22][20010];
lint minCost[111];

int djk() {
	fill(minCost, minCost + 111, lINF);
	priority_queue< Edge, vector< Edge >, greater< Edge > > que;
	que.push(Edge(s, 0));
	minCost[s] = 0;
	
	while (!que.empty()) {
		Edge e = que.top(); que.pop();
		int u = e.to, dst = e.dst;
		
		if (minCost[u] < dst) continue;
		
		for_(ci,0,c) {
			for_(v,0,n) {
				if (cost[ci][u][v] == iINF) continue;
				
				int nx_cost = dst + cost[ci][u][v];
				if (minCost[v] > nx_cost) {
					minCost[v] = nx_cost;
					que.push(Edge(v, nx_cost));
				}
			}
		}
	}
	
	return (minCost[g] == lINF) ? -1 : minCost[g];
}

void solve() {
	for_(ci,0,c) {
		for_(k,0,n) for_(i,0,n) for_(j,0,n) {
			minUpdate(dist[ci][i][j], dist[ci][i][k] + dist[ci][k][j]);
		}
	}
	
	for_(ci, 0, c) {
		for_(u,0,n) for_(v,0,n) {
			if (dist[ci][u][v] == iINF) {
				cost[ci][u][v] = iINF;
				continue;
			}
			
			assert(dist[ci][u][v] <= 20000);
			cost[ci][u][v] = price[ci][dist[ci][u][v]];
		}
	}
	
	cout << djk() << endl;
}

int main() {
	while (cin >> n >> m >> c >> s >> g, n) {
		--s; --g;
		
		for_(i,0,22) for_(j,0,111) for_(k,0,111) dist[i][j][k] = iINF;
		
		edges.assign(n, vector< Edge >());
		
		for_(i,0,m) {
			int x, y, cmp; lint dst;
			cin >> x >> y >> dst >> cmp;
			--x; --y; --cmp;
			edges[x].push_back(Edge(y, dst));
			edges[y].push_back(Edge(x, dst));
			dist[cmp][x][y] = dist[cmp][y][x] = min(dist[cmp][y][x], dst);
		}
		
		for_(ci,0,c) cin >> p[ci];
		
		minit(price, 0);
		
		for_(ci,0,c) {
			for_(j,0,p[ci]-1) cin >> q[ci][j];
			for_(j,0,p[ci]) cin >> r[ci][j];
			q[ci][p[ci]-1] = 20005;
			
			int cur = 1;			
			for_(j,0,p[ci]) {
				int qj = q[ci][j];
				while (cur <= q[ci][j]) {
					price[ci][cur] = price[ci][cur - 1] + r[ci][j];
					++cur;
				}
			}
		}
		
		solve();
	}
}