#include <iostream>
#include <vector>

using namespace std;

const int MN = 110;
const int INF = 1<<29;
int sd[22][MN][MN];
int dist[MN][MN];
bool solve() {
	int n, m, C, s, g;
	cin >> n >> m >> C >> s >> g; s--; g--;
	if (!n) return false;
	for (int c = 0; c < C; c++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				sd[c][i][j] = INF;
			}
			sd[c][i][i] = 0;
		}
	}
	for (int i = 0; i < m; i++) {
		int x, y, d, c;
		cin >> x >> y >> d >> c; x--; y--; c--;
		d = min(d, sd[c][x][y]);
		sd[c][x][y] = sd[c][y][x] = d;
	}

	for (int c = 0; c < C; c++) {
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					sd[c][i][j] = min(sd[c][i][j], sd[c][i][k]+sd[c][k][j]);
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dist[i][j] = INF;
		}
		dist[i][i] = 0;
	}
	int p[22];
	for (int i = 0; i < C; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < C; i++) {
		static int cost[20200];
		vector<int> qv, ev;
		qv.push_back(0);
		for (int j = 0; j < p[i]-1; j++) {
			int x;
			cin >> x;
			qv.push_back(x);
		}
		qv.push_back(20199);
		for (int j = 0; j < p[i]; j++) {
			int x;
			cin >> x;
			ev.push_back(x);
		}
		cost[0] = 0;
		for (int j = 1; j <= p[i]; j++) {
			for (int l = qv[j-1]+1; l <= qv[j]; l++) {
				cost[l] = cost[l-1] + ev[j-1];
			}
		}
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (sd[i][j][k] == INF) continue;
				dist[j][k] = min(dist[j][k], cost[sd[i][j][k]]);
			}
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}
	
	if (dist[s][g] == INF) dist[s][g] = -1;
	cout << dist[s][g] << endl;
	return true;
}

int main() {
	while (solve()) {}
	return 0;
}