#include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

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


int dist[21][100][100];
int cost[20][20010];

int main(void){
	while(1){
		cin >> n >> m >> c >> s >> g;
		if(n==0&&m==0) break;
		s--,g--;
		rep(i,c+1)rep(j,n)rep(k,n) dist[i][j][k]=(j==k)?0:inf;
		rep(i,c)rep(j,20010) cost[i][j]=0;

		rep(i,m){
			int x,y,d,t;
			cin >> x >> y >> d >> t;
			x--,y--;
			dist[t][x][y]=min(dist[t][x][y],d);
			dist[t][y][x]=min(dist[t][y][x],d);
		}

		rep(i,c) cin >> p[i];
		rep(i,c){
			rep(j,p[i]-1) cin >> q[i][j];
			rep(j,p[i]) cin >> r[i][j];
			int cur=1,index=0;
			while(cur<=20000){
				cost[i][cur]=cost[i][cur-1]+r[i][index];
				if(index!=(p[i]-1)&&cur==q[i][index]) index++;
				cur++;
			}
		}

		range(a,1,c+1)rep(k,n)rep(i,n)rep(j,n) dist[a][i][j]=min(dist[a][i][j],dist[a][i][k]+dist[a][k][j]);

		range(a,1,c+1)rep(i,n)rep(j,n)
			if(dist[a][i][j]!=inf)
				dist[0][i][j]=min(dist[0][i][j],cost[a-1][dist[a][i][j]]);

		rep(k,n)rep(i,n)rep(j,n) dist[0][i][j]=min(dist[0][i][j],dist[0][i][k]+dist[0][k][j]);

		if(dist[0][s][g]>=inf)
			cout << -1 << endl;
		else
			cout << dist[0][s][g] << endl;
	}
 	return 0;
}