#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cctype>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e7;
int n, m, c, s, g;
VVI q, r, d;

int calc_cost(int rail, int dist){
    int res = 0;
    int p = r[rail].size();
    REP(i,p){
        if (dist < q[rail][i]){
            if (i == 0) res += dist * r[rail][i];
            else res += (dist - q[rail][i-1]) * r[rail][i];
            break;
        }else{
            if (i == 0) res += q[rail][i] * r[rail][i];
            else res += (q[rail][i] - q[rail][i-1]) * r[rail][i];
        }
    }
    return res;
}

int main() {
    while (cin >> n >> m >> c >> s >> g && n){
        s--;
        g--;
        q.clear();
        r.clear();
        q.resize(c);
        r.resize(c);
        vector<VVI> dist(c, VVI(n, VI(n, INF)));
        REP(i,c) REP(j,n) dist[i][j][j] = 0;
        while (m--){
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            x--;
            y--;
            c--;
            dist[c][x][y] = min(dist[c][x][y], d);
            dist[c][y][x] = min(dist[c][y][x], d);
        }
        VI p(c);
        REP(i,c) cin >> p[i];
        REP(i,c){
            q[i].resize(p[i]-1);
            r[i].resize(p[i]);
            REP(j,p[i]-1) cin >> q[i][j];
            q[i].push_back(INF);
            REP(j,p[i]) cin >> r[i][j];
        }

        REP(r,c) REP(i,n) REP(j,n) REP(k,n) dist[r][j][k] = min(dist[r][j][k], dist[r][j][i] + dist[r][i][k]);

        VVI cost(n, VI(n, INF));
        REP(r,c) REP(i,n) REP(j,n){
            cost[i][j] = min(cost[i][j], calc_cost(r, dist[r][i][j]));
        }

        REP(i,n) REP(j,n) REP(k,n) cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);

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