#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<tuple>
#include<queue>
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
using namespace std;

typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
typedef tuple<int,int,int,int> tp;
const int inf = 1e9;
const ll INF = 2e18;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
vi p;
vvi q,r;
Def d[110][21][110];
Def wa[21][110][110];
class DIJ{
	public:
	struct edge{
		Def to,cost,com;
	};
	vector<vector<edge> > G;
	Def n,L;
	DIJ(Def size, Def l = 1){
		n = size;
		L = l;
		G = vector<vector<edge> >(n);
	}
	void syoki(){
		rep(i,21)rep(j,110)rep(k,110)wa[i][j][k]=inf;
		rep(i,21)rep(j,110)wa[i][j][j]=0;

	}
	void add_edge(Def a, Def b, Def c,Def d){
		edge e = {b,c,d}, ee = {a,c,d};
		G[a].pb(e);
		G[b].pb(ee);
		wa[d][a][b]=wa[d][b][a]=min(c,wa[d][a][b]);
	}
	void wa_shal(){
		rep(q,21)rep(i,n)rep(j,n)rep(k,n){
			wa[q][j][k]=min(wa[q][j][i]+wa[q][i][k],wa[q][j][k]);
		}
	}
	int g(int com,int d){
		int s=0;
		int j;
		for(j=0;j<p[com]-1;j++){
			if(d<q[com][j+1])break;
			s+=(q[com][j+1]-q[com][j])*r[com][j];
		}
		return (d-q[com][j])*r[com][j]+s;
	}
	int f(int com,int pre,int pos,int to){
		int ret=max(0,g(com,wa[com][pre][to])-g(com,wa[com][pre][pos]));
//		cout<<com<<" "<<pre<<" "<<pos<<" "<<to<<" "<<ret<<endl;
		return ret;
	}
	void dij(Def a, Def b){
		rep(i,110) rep(j,21) rep(k,110) d[i][j][k] = inf;
		d[a][0][a] = 0;
		priority_queue<tp> q;
		q.push(tp(0,a,0,a));
		while(!q.empty()){
			Def pos,com,pre,cost;//cost, pos, t;
			tie(cost,pos,com,pre) = q.top();
			cost *= -1;
			q.pop();
			if(cost > d[pos][com][pre]) continue;
//			cout<<cost<<" "<<pos<<" "<<com<<" "<<pre<<endl;
			rep(i,G[pos].size()){
				edge e = G[pos][i];
				Def to = e.to;
				Def ncom = e.com;//(a * v + b) % c;
				Def ncost = cost;//+f(e.com,pos,to);// + e.cost * v;
				Def npre;//=pos;
				if(com==ncom){
					ncost+=f(e.com,pre,pos,to);
					npre=pre;
				}else{
					ncost+=f(e.com,pos,pos,to);
					npre=pos;
				}
				if(ncost < d[to][ncom][npre]){
					d[to][ncom][npre] = ncost;
					q.push(tp(-ncost, to, ncom, npre));
				}
			}
		}
		int out = inf;
		rep(i,21)rep(j,110) out = min(out, d[b][i][j]);
		if(out==inf)cout<<-1<<endl;
		else cout << out << endl;
	}
};
int main(){
	int n,m,c,s,g;
	while(cin>>n>>m>>c>>s>>g,n){
		DIJ dij(n);
		dij.syoki();
		rep(i,m){
			int x,y,d,C;
			cin>>x>>y>>d>>C;
			dij.add_edge(x-1,y-1,d,C-1);
		}
		p=vi(c);
		rep(i,c)cin>>p[i];
		q=vvi(c);
		r=vvi(c);
		rep(i,c){
			q[i]=vi(p[i]);
			rep(j,p[i]-1)cin>>q[i][j+1];
			r[i]=vi(p[i]);
			rep(j,p[i])cin>>r[i][j];
		}
		dij.wa_shal();
		dij.dij(s-1,g-1);
	}
}