/*
Railway Connection(https://onlinejudge.u-aizu.ac.jp/problems/1182)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;


void solve(void){
	int N, M, C, S, G;

	while (cin >> N >> M >> C >> S >> G) {
		if (!N) break;
		S--, G--;

		//dis[c][x][y] := cを使ってxからyに行く時の最短経路
		vector <mat> dis(C, mat (N, vec (N, INF)));

		rep(M, i)
		{
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--, y--, c--;
			dis[c][x][y] = dis[c][y][x] = min(dis[c][x][y], d);
		}

		rep(C, c)
		{
			//各Cの距離についてWF
			rep(N, k) rep(N, i) rep(N, j)
			{
				dis[c][i][j] = min(dis[c][i][j], dis[c][i][k] + dis[c][k][j]);
			}
		}

		vec ps(C);
		rep(C, i) cin >> ps[i];

		//cost[x][y] := xからyに行く時の最低コスト
		mat cost(N, vec(N, INF));

		rep(C, c)
		{
			vec qs(ps[c]+1, 0), rs(ps[c]);
			//qs[0] = 0, qs[ps[i]] = INF
			qs[ps[c]] = INF;
			rep(ps[c]-1, j) cin >> qs[j+1];
			rep(ps[c], j) cin >> rs[j];

			rep(N, x) rep(N, y)
			{
				int d = dis[c][x][y];
				if (d == INF)
				{
					continue;
				}

				int fare = 0;
				rep(ps[c]+1, p)
				{
					if (d > qs[p])
					{
						fare += min(qs[p+1]-qs[p], d-qs[p]) * rs[p];
					}
				}

				cost[x][y] = min(cost[x][y], fare);

			}

		}

		//コストについてWF
		rep(N, k) rep(N, i) rep(N, j)
		{
			cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
		}

		if (cost[S][G] == INF)
		{
			cout << -1 << endl;
		}
		else
		{
			cout << cost[S][G]  << endl;
		}

	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}

