#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

const int INF = 1 << 28;
int rec[21][110][110], dp[110][110], P[21];
int main() {
    int N, M, C, s, g;
    while(1) {
        scanf(" %d%d%d%d%d", &N, &M, &C, &s, &g);
        if(!N) break;
        s--; g--;

        // init
        for(int j=0; j<N; j++) {
            for(int k=0; k<N; k++) {
                for(int i=0; i<C; i++) {
                    rec[i][j][k] = (j == k ? 0 : INF);
                }
                dp[j][k] = INF;
            }
        }

        for(int i=0; i<M; i++) {
            int x, y, d, c; scanf(" %d%d%d%d", &x, &y, &d, &c);
            x--; y--; c--;
            rec[c][x][y] = min(rec[c][x][y], d);
            rec[c][y][x] = min(rec[c][y][x], d);
        }

        for(int t=0; t<C; t++) {
            for(int k=0; k<N; k++) {
                for(int i=0; i<N; i++) {
                    for(int j=0; j<N; j++) {
                        rec[t][i][j] = min(rec[t][i][j], rec[t][i][k] + rec[t][k][j]);
                    }
                }
            }
        }

        // 料金表
        for(int i=0; i<C; i++) {
            scanf(" %d", &P[i]);
        }
        vector< vector<int> > Q(C), R(C), sum(C);
        for(int i=0; i<C; i++) {
            sum[i].push_back(0);
            Q[i].push_back(0);
            for(int k=0; k<P[i]-1; k++) {
                int q; scanf(" %d", &q);
                Q[i].push_back(q);
            }

            for(int k=0; k<P[i]; k++) {
                int r; scanf(" %d", &r);
                if(k != P[i] - 1) {
                    int diff = Q[i][k+1] - Q[i][k];
                    sum[i].push_back(sum[i].back() + diff * r);
                }
                R[i].push_back(r);
            }

            /*
            printf("sum:");
            for(auto x : sum[i]) {
                printf(" %d", x);
            }
            printf("\n");

            printf("Q:");
            for(auto x : Q[i]) {
                printf(" %d", x);
            }
            printf("\n");

            printf("R:");
            for(auto x : R[i]) {
                printf(" %d", x);
            }
            printf("\n");
            */
        }

        for(int t=0; t<C; t++) {
            for(int i=0; i<N; i++) {
                for(int j=i+1; j<N; j++) {
                    if(i == j || rec[t][i][j] == INF) continue;
                    int cost = rec[t][i][j];
                    int idx = upper_bound(Q[t].begin(), Q[t].end(), cost) - Q[t].begin() - 1;
                    // printf("idx = %d\n", idx);
                    int value = sum[t][idx] + (cost - Q[t][idx]) * R[t][idx];
                    // printf("company %d, edge: %d <-> %d (cost = %d, value = %d)\n", t, i, j, cost, value);
                    dp[i][j] = min(dp[i][j], value);
                    dp[j][i] = min(dp[j][i], value);
                }
            }
        }

        for(int k=0; k<N; k++) {
            for(int i=0; i<N; i++) {
                for(int j=0; j<N; j++) {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }

        if(dp[s][g] == INF) printf("-1\n");
        else printf("%d\n", dp[s][g]);
    }
    return 0;
}


Measured memory_bytes: 3608