#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

#define int long long
struct Edge {
  int to;
  int own;
  int len;
};

int N;
int M;
int C;
int S;
int G;
using Tup = tuple<int, int, int>;
using Pair = pair<int, Tup>;
int mat[21][114][114];
int mind[114];
int P[21];
int Q[21][51];
int R[21][51];

int Calc(int c, int l) {
  int ret = 0;
  reps(i, 1, P[c]+1) {
    if (l < Q[c][i]) {
      ret += (l - Q[c][i-1]) * R[c][i-1];
      break;
    }
    ret += (Q[c][i]-Q[c][i-1])*R[c][i-1];
  }
  return ret;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  while (1) {
    cin >> N >> M >> C >> S >> G;
    if (N == 0) return 0;

    --S;
    --G;

    fill(mat[0][0], mat[C][0], MOD);
    rep(c, C) {
      rep(v, N) {
        mat[c][v][v] = 0;
      }
    }

    rep(i, M) {
      int u, v;
      int d, c;
      cin >> u >> v >> d >> c;
      --u;
      --v;
      --c;

      MN(mat[c][u][v], d);
      MN(mat[c][v][u], d);
    }

    rep(c, C) {
      rep(w, N) {
        rep(v, N) {
          rep(u, N) {
            MN(mat[c][v][u], mat[c][v][w] + mat[c][w][u]);
          }
        }
      }
    }

    rep(c, C) {
      cin >> P[c];
    }

    rep(c, C) {
      reps(i, 1, P[c]) {
        cin >> Q[c][i];
      }
      Q[c][0] = 0;
      Q[c][P[c]] = MOD;
      rep(i, P[c]) {
        cin >> R[c][i];
      }
    }

    priority_queue<pii, vector<pii>, greater<pii>> que;
    fill(mind, mind+N, MOD);
    mind[S] = 0;
    que.push(pii(0, S));
    while (!que.empty()) {
      pii pa = que.top(); que.pop();
      int cost = pa.X;
      int v = pa.Y;

      if (mind[v] < cost) continue;
      rep(u, N) {
        if (u == v) continue;
        rep(c, C) {
          if (mat[c][v][u] == MOD) continue;
          int nc = cost + Calc(c, mat[c][v][u]);
          if (mind[u] > nc) {
            mind[u] = nc;
            que.push(pii(mind[u], u));
          }
        }
      }
    }

    int ans = mind[G];
    if (ans == MOD) cout << "-1" << "\n";
    else cout << ans << "\n";
  }
}

