#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

template<typename T>
void chmin(T& a,const T& b){
	a=min(a,b);
}

int main()
{
	for(int n,m,c,s,t;cin>>n>>m>>c>>s>>t,n|m|c|s|t;){
		s--; t--;
		vector<vvi> dists(c,vvi(n,vi(n,INFTY)));
		rep(i,c) rep(j,n) dists[i][j][j]=0;
		rep(i,m){
			int x,y,d,c; cin>>x>>y>>d>>c; x--; y--; c--;
			chmin(dists[c][x][y],d);
			chmin(dists[c][y][x],d);
		}
		vi ps(c);
		rep(i,c) cin>>ps[i];
		vvi sums(c,vi(20000));
		rep(i,c){
			vi qs(ps[i]),rs(ps[i]);
			rep(j,ps[i]-1) cin>>qs[j+1];
			rep(j,ps[i])   cin>>rs[j];
			rep(j,ps[i]-1) repi(k,qs[j],qs[j+1])
				sums[i][k+1]=sums[i][k]+rs[j];
			repi(k,qs[ps[i]-1],20000)
				sums[i][k+1]=sums[i][k]+rs[ps[i]-1];
		}
		
		for(vvi& dist:dists)
			rep(k,n) rep(i,n) rep(j,n)
				chmin(dist[i][j],dist[i][k]+dist[k][j]);
		
		vvi dp(n,vi(n,INFTY));
		rep(i,n) rep(j,n) rep(k,c) if(dists[k][i][j]!=INFTY)
			chmin(dp[i][j],sums[k][dists[k][i][j]]);
		
		rep(k,n) rep(i,n) rep(j,n)
			chmin(dp[i][j],dp[i][k]+dp[k][j]);
		
		cout<<(dp[s][t]==INFTY?-1:dp[s][t])<<endl;
	}
	
	return 0;
}