#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e12;

int p[21], q[21][51], r[21][51];
int costTable[21][100010];
int d[21][110][110];

signed main(){
    int n, m, c, s, g;
    while(cin >> n >> m >> c >> s >> g, n){
        s--; g--;
        rep(i, 0, c + 1){
            rep(j, 0, n){
                rep(k, 0, n){
                    d[i][j][k] = INF;
                }
                d[i][j][j] = 0;
            }
        }
        memset(p, 0, sizeof(p));
        memset(q, 0, sizeof(q));
        memset(r, 0, sizeof(r));
        memset(costTable, 0, sizeof(costTable));
        rep(i, 0, m){
            int x, y, di, ci;
            cin >> x >> y >> di >> ci;
            x--; y--; ci--;
            d[ci][x][y] = min(d[ci][x][y], di);
            d[ci][y][x] = min(d[ci][y][x], di);
        }
        rep(i, 0, c){
            cin >> p[i];
        }
        rep(i, 0, c){
            rep(j, 0, p[i] - 1) cin >> q[i][j];
            rep(j, 0, p[i]) cin >> r[i][j];
        }
        rep(i, 0, c){
            int idx = 0;
            costTable[i][0] = 0;
            rep(j, 1, 100010){
                costTable[i][j] = costTable[i][j - 1] + r[i][idx];
                // if(j <= 10) cout << i << ' ' << j << ' ' << costTable[i][j] << endl;
                if(j == q[i][idx]) idx++;
            }
        }
        rep(l, 0, c){
            rep(k, 0, n){
                rep(i, 0, n){
                    rep(j, 0, n){
                        d[l][i][j] = min(d[l][i][j], d[l][i][k] + d[l][k][j]);
                    }
                }
            }
        }
        rep(i, 0, n){
            rep(j, 0, n){
                rep(k, 0, c){
                    if(d[k][i][j] >= 100010) continue;
                    int tmp = costTable[k][d[k][i][j]];
                    d[c][i][j] = min(d[c][i][j], tmp);
                }
                // cout << i << ' ' << j << ' ' << d[c][i][j] << endl;
            }
        }
        rep(k, 0, n){
            rep(i, 0, n){
                rep(j, 0, n){
                    d[c][i][j] = min(d[c][i][j], d[c][i][k] + d[c][k][j]);
                }
            }
        }
        if(d[c][s][g] >= INF) cout << -1 << endl;
        else cout << d[c][s][g] << endl;
    }
}
