#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

struct Edge
{
	int to, dist;
	Edge( int t, int d ) : to( t ), dist( d )
	{
		return;
	}
};

typedef vector< vector<Edge> > Graph;

VI dijkstra( const Graph &G, int s )
{
	const int V = G.size();

	VI distance( V, INT_MAX );
	distance[s] = 0;
	priority_queue< PII, vector<PII>, greater<PII> > que;
	que.push( MP( 0, s ) );
	while ( !que.empty() )
	{
		int dist = que.top().fst;
		int cur = que.top().snd;
		que.pop();

		if ( distance[ cur ] < dist )
		{
			continue;
		}

		REP( i, 0, G[ cur ].size() )
		{
			const Edge &e = G[ cur ][i];
			if ( distance[ e.to ] <= distance[ cur ] + e.dist )
			{
				continue;
			}
			distance[ e.to ] = distance[ cur ] + e.dist;
			que.push( MP( distance[ e.to ], e.to ) );
		}
	}

	return distance;
}

int calcCost( int p, const VI &qs, const VI &rs, int d )
{
	int res = 0;

	for ( int i = 0; i < qs.size() - 1 && qs[i] <= d; ++i )
	{
		if ( qs[ i + 1 ] < d )
		{
			res += ( qs[ i + 1 ] - qs[i] ) * rs[i];
		}
		else
		{
			res += ( d - qs[i] ) * rs[i];
		}
	}

	return res;
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	while ( true )
	{
		int n, m, c, s, g;
		cin >> n >> m >> c >> s >> g;

		if ( !( n | m | c | s | g ) )
		{
			break;
		}

		s--;
		g--;

		vector< Graph > G( c, Graph( n ) );
		REP( i, 0, m )
		{
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--;
			y--;
			c--;

			G[c][x].PB( Edge( y, d ) );
			G[c][y].PB( Edge( x, d ) );
		}

		VI ps( c );
		FOR( p, ps )
		{
			cin >> p;
		}

		VVI qss( c ), rss( c );
		REP( i, 0, c )
		{
			qss[i].resize( ps[i] - 1 );
			FOR( q, qss[i] )
			{
				cin >> q;
			}
			qss[i].insert( qss[i].begin(), 0 );
			qss[i].PB( INT_MAX );

			rss[i].resize( ps[i] );
			FOR( r, rss[i] )
			{
				cin >> r;
			}
		}
		// 入力終わり

		VI cost( n, INT_MAX );
		cost[s] = 0;
		priority_queue< PII, vector<PII>, greater<PII> > que;
		que.push( MP( 0, s ) );
		while ( !que.empty() )
		{
			int ccost = que.top().fst;
			int cur = que.top().snd;
			que.pop();

			if ( cost[ cur ] < ccost )
			{
				continue;
			}

			REP( ic, 0, c )
			{
				VI dist( dijkstra( G[ ic ], cur ) );
				REP( in, 0, n )
				{
					if ( dist[ in ] == INT_MAX )
					{
						continue;
					}

					int ncost = calcCost( ps[ ic ], qss[ ic ], rss[ ic ], dist[ in ] );
					if ( cost[ in ] <= cost[ cur ] + ncost )
					{
						continue;
					}
					cost[ in ] = cost[ cur ] + ncost;
					que.push( MP( cost[ in ], in ) );
				}
			}
		}

		cout << ( cost[g] == INT_MAX ? -1 : cost[g] ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1512