#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
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();}
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 EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
const ll MAX=LONG_MAX/10;

ll getcost(int distance,vi &q,vi &r,vl &stacked_cost){
	int index=lower_bound(ALL(q),distance)-q.begin();
	int cost=stacked_cost[index]+(distance-(index>0?q[index-1]:0))*r[index];
	return cost;
}
struct node{
    int index;ll cost;
    node(int index,ll cost):index(index),cost(cost){}
    bool operator<(const node& other)const{
        return cost>other.cost;
    }
};
const ll NONE=-1;
int main(){
	int n,m,c,s,g;
	while(cin>>n>>m>>c>>s>>g,n){
		vvvl dist(c,vvl(n,vl(n,MAX)));
		REP(i,m){
			int x,y,d,c;
			cin>>x>>y>>d>>c;
			dist[c-1][x-1][y-1]=min((ll)d,dist[c-1][x-1][y-1]);
			dist[c-1][y-1][x-1]=min((ll)d,dist[c-1][y-1][x-1]);
		}
		vi p(c);
		REP(i,c){
			cin>>p[i];
		}
		vvi q(c),r(c);
		REP(i,c){
			REP(j,p[i]-1){
				int qq;
				cin>>qq;
				q[i].push_back(qq);
			}
			REP(j,p[i]){
				int rr;
				cin>>rr;
				r[i].push_back(rr);
			}
		}

		vvl stacked_cost(c);
		REP(i,c){
			int cur=0;
			stacked_cost[i].push_back(0);
			FOR(j,1,p[i]){
				stacked_cost[i].push_back(stacked_cost[i][j-1]+(q[i][j-1]-(j>1?q[i][j-2]:0))*r[i][j-1]);
			}
		}

		REP(comp,c){
			REP(i,n){
				dist[comp][i][i]=0;
			}
			REP(k,n){
				REP(i,n){
					REP(j,n){
						dist[comp][i][j]=min(dist[comp][i][j],dist[comp][i][k]+dist[comp][k][j]);
					}
				}
			}
		}

		vvvl cost_btw_stations(c,vvl(n,vl(n,NONE)));
		REP(comp,c){
			REP(i,n){
				REP(j,n){
					if(dist[comp][i][j]!=MAX){
						cost_btw_stations[comp][i][j]=getcost(dist[comp][i][j],q[comp],r[comp],stacked_cost[comp]);
					}
				}
			}
		}

		priority_queue<node> Q;
		Q.push(node(s-1,0));
		vl dijkcost(n,MAX);
		dijkcost[s-1]=0;
		while(!Q.empty()){
			node cnode=Q.top();Q.pop();
			if(dijkcost[cnode.index]<cnode.cost){
				continue;
			}
			REP(i,n){
				REP(comp,c){
					if(i!=cnode.index&&cost_btw_stations[comp][cnode.index][i]!=NONE){
						ll newcost=cnode.cost+cost_btw_stations[comp][cnode.index][i];
						if(dijkcost[i]>newcost){
							dijkcost[i]=newcost;
							Q.push(node(i,newcost));
						}
					}
				}
			}
		}
		cout<<(dijkcost[g-1]==MAX?-1:dijkcost[g-1])<<endl;
	}
}

Measured memory_bytes: 4716