#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#define NA 1000000000

int n, m, c, s, g;
int p[20];
int q[20][50];
int r[20][50];

int distances[20][100][100];
int fares[20][100][100];
int faresConsideredAllCompany[100][100];

void init()
{
	int company, i, j;
	for (company = 0; company < 20; ++company)
	{
		for (i = 0; i < 100; ++i)
		{
			for (j = 0; j < 100; ++j)
			{
				distances[company][i][j] = faresConsideredAllCompany[i][j] = (i == j ? 0 : NA);
			}
		}
	}
}

int getCost(int company, int distance)
{
	if (distance == NA) { return NA; }
	if (distance == 0) { return 0; }

	int result = 0;
	int i;
	for (i = 0;; ++i)
	{
		if (distance <= q[company][i + 1])
		{
			return result + (distance - q[company][i]) * r[company][i];
		}

		result += (q[company][i + 1] - q[company][i]) * r[company][i];
	}
}

void getMinimumDistances()
{
	int i, j, k, company;
	for (company = 0; company < c; ++company)
	{
		for (k = 0; k < n; ++k)
		{
			for (i = 0; i < n; ++i)
			{
				for (j = 0; j < n; ++j)
				{
					if (distances[company][i][j] > distances[company][i][k] + distances[company][k][j])
					{
						distances[company][i][j] = distances[company][i][k] + distances[company][k][j];
					}
				}
			}
		}
	}
}

void getMinimumFare()
{
	int i, j, company;
	for (i = 0; i < n; ++i)
	{
		for (j = 0; j < n; ++j)
		{
			for (company = 0; company < c; ++company)
			{
				fares[company][i][j] = getCost(company, distances[company][i][j]);
				if (fares[company][i][j] < faresConsideredAllCompany[i][j])
				{
					faresConsideredAllCompany[i][j] = fares[company][i][j];
				}
			}
		}
	}
}

int solve()
{
	getMinimumDistances();
	getMinimumFare();

	int i, j, k;
	for (k = 0; k < n; ++k)
	{
		for (i = 0; i < n; ++i)
		{
			for (j = 0; j < n; ++j)
			{
				if (faresConsideredAllCompany[i][j] > faresConsideredAllCompany[i][k] + faresConsideredAllCompany[k][j])
				{
					faresConsideredAllCompany[i][j] = faresConsideredAllCompany[i][k] + faresConsideredAllCompany[k][j];
				}
			}
		}
	}

	return (faresConsideredAllCompany[s - 1][g - 1] == NA ? -1 : faresConsideredAllCompany[s - 1][g - 1]);
}

int main()
{
	int i, company;
	while (true)
	{
		scanf("%d %d %d %d %d", &n, &m, &c, &s, &g);
		if (n == 0) { break; }

		init();

		for (i = 0; i < m; ++i)
		{
			int x, y, d, company;
			scanf("%d %d %d %d", &x, &y, &d, &company);
			if (distances[company - 1][x - 1][y - 1] > d)
			{
				distances[company - 1][x - 1][y - 1] = distances[company - 1][y - 1][x - 1] = d;
			}
		}

		for (company = 0; company < c; ++company) { scanf("%d", &p[company]); }
		for (company = 0; company < c; ++company)
		{
			for (i = 1; i < p[company]; ++i) { scanf("%d", &q[company][i]); }
			q[company][0] = 0;
			q[company][p[company]] = NA;
			for (i = 0; i < p[company]; ++i) { scanf("%d", &r[company][i]); }
		}

		printf("%d\n", solve());
	}

	return 0;
}
