#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = (1l << 30);
const long LINF = (1l << 60);

typedef std::pair<long, long> P;

long rail[25][105][105];//[company][station][station]
long n, m, c, s, g;
std::vector<P> edge[105];//dist, to
long seg[25];
std::vector<long> bound[25];
std::vector<long> rate[25];
long dist[105];
long ans;

long cost_cal(long com, long len){
    long ret = 0;
    for(long i = 0; bound[com][i] < len; i++){
        ret += (std::min(bound[com][i+1], len) - bound[com][i]) * rate[com][i];
    }
    return ret;
}

void dijkstra(){
    std::priority_queue<P, std::vector<P>, std::greater<P> > que;
    que.push(P(0, s));
    dist[s] = 0;
    while(!que.empty()){
        P p = que.top();
        que.pop();
        long vis = p.second;
        long d = p.first;
        if(dist[vis] < d){
            continue;
        }
        for(int i = 0; i < edge[vis].size(); i++){
            P nx = edge[vis][i];
            if(dist[nx.second] > dist[vis] + nx.first){
                dist[nx.second] = dist[vis] + nx.first;
                que.push(P(dist[nx.second], nx.second));
            }
        }
    }
    return;
}

void solve(){
    for(int i = 1; i <= c; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                rail[i][j][k] = LINF;
            }
        }
    }
    for(int i = 0; i < m; i++){
        long x, y, d, com;
        scanf("%ld%ld%ld%ld", &x, &y, &d, &com);
        rail[com][x][y] = rail[com][y][x] = std::min(rail[com][x][y], d);
    }
    for(int com = 1; com <= c; com++){
        for(int k = 1; k <= n; k++){
            for(int i = 1; i <= n; i++){
                for(int j = 1; j <= n; j++){
                    rail[com][i][j] = std::min(rail[com][i][j], rail[com][i][k] + rail[com][k][j]);
                }
            }
        }
        /*
        for(int j = 0; j <= n; j++){
            printf(" %3d", j);
        }
        printf("\n");
        for(int i = 1; i <= n; i++){
            printf(" %3d", i);
            for(int j = 1; j <= n; j++){
                if(rail[com][i][j] == LINF){
                    printf(" INF");
                }else{
                    printf(" %3ld", rail[com][i][j]);
                }
            }
            printf("\n");
        }
        printf("\n");
        //*/
    }
    for(int i = 1; i <= c; i++){
        scanf("%ld", &seg[i]);
    }
    for(int com = 1; com <= c; com++){
        bound[com].push_back(0);
        for(int i = 0; i < seg[com] - 1; i++){
            long q;
            scanf("%ld", &q);
            bound[com].push_back(q);
        }
        bound[com].push_back(LINF);
        for(int i = 0; i < seg[com]; i++){
            long r;
            scanf("%ld", &r);
            rate[com].push_back(r);
        }
        /*
        for(int i = 0; i < bound[com].size(); i++){
            printf("%3ld   ", bound[com][i]);
        }
        printf("\n");
        for(int i = 0; i < rate[com].size(); i++){
            printf("   %3ld", rate[com][i]);
        }
        printf("\n");
        //*/
    }
    //printf("pass\n");
    for(int com = 1; com <= c; com++){
        for(long i = 1; i <= n; i++){
            for(long j = 1; j <= n; j++){
                if(i == j){
                    continue;
                }
                if(rail[com][i][j] != LINF){
                    long cost = cost_cal(com, rail[com][i][j]);
                    //printf("  %ld->%ld %ld %ld\n", i, j, rail[com][i][j], cost);
                    edge[i].push_back(P(cost, j));
                    edge[j].push_back(P(cost, i));
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        dist[i] = LINF;
    }

    dijkstra();
    if(dist[g] == LINF){
        printf("-1\n");
    }else{
        printf("%ld\n", dist[g]);
    }
}

int main(){
    while(1){
        scanf("%ld%ld%ld%ld%ld", &n, &m, &c, &s, &g);
        if(n == 0){
            return 0;
        }
        solve();
        for(int i = 0; i < 105; i++){
            edge[i].clear();
        }
        for(int i = 0; i < 25; i++){
            bound[i].clear();
            rate[i].clear();
        }
    }
}



Measured memory_bytes: 11608