#include <bits/stdc++.h> // {{{

#define ARG5(a, b, c, d, NAME, ...) NAME
#define REP(...) ARG5(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__)
#define REP1(a) REP2(i, a)
#define REP2(i, a) REP3(i, 0, a)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += (s))
#define REPR(...) ARG5(__VA_ARGS__, REPR4, REPR3, REPR2)(__VA_ARGS__)
#define REPR1(a) REPR2(i, a)
#define REPR2(i, a) REPR3(i, 0, a)
#define REPR3(i, a, b) REPR4(i, a, b, 1)
#define REPR4(i, a, b, s) for (int i = (b)-1; i >= (int)(a); i -= (s))
#define ALL(c) (c).begin(), (c).end()
#define DUMP(x) (std::cerr << #x << ':' << ' ' << x << '\n')
#define TMPL_T template <typename T>
#define TMPL_TU template <typename T, typename U>
#define mut auto
#define let const auto

using Int = long long;
// clang-format off
namespace extio {
std::string delimiter=" ",pdelimiter=" ";
std::string bracket_b="",bracket_e="";
void chdelim(const std::string&s){delimiter=s;}
void chpdelim(const std::string&s){pdelimiter=s;}
void chbracket(const std::string&b,const std::string&e){bracket_b=b,bracket_e=e;}
TMPL_T  void pcont(std::ostream&os,const T&x){int c=0;for(const auto&a:x){if(c++)os<<delimiter;os<<a;}}
TMPL_TU void ppair(std::ostream&os,const std::pair<T,U>&p){os<<bracket_b<<p.first<<pdelimiter<<p.second<<bracket_e;}
TMPL_T void read_seq(std::vector<T>&seq,int N){REP(N){T x;std::cin>>x;seq.emplace_back(x);}}
}
namespace std {
TMPL_T ostream& operator<<(ostream&os,const vector<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const set<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const multiset<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const deque<T>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const map<T,U>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const pair<T,U>&x){extio::ppair(os,x);return os;}
TMPL_T istream& operator>>(istream&is,tuple<int&,vector<T>&>x)
{int N=get<0>(x);vector<T>&v=get<1>(x);v.clear();v.reserve(N);REP(i,N){T a;is>>a;v.emplace_back(a);}return is;}
TMPL_T istream& operator>>(istream&is,tuple<vector<T>&,int&>x){return is>>tie(get<1>(x),get<0>(x));}
TMPL_T istream& operator>>(istream&is,tuple<int&,T*>x){int N=get<0>(x);T*v=get<1>(x);REP(i,N){is>>v[i];}return is;}
TMPL_T istream& operator>>(istream&is,tuple<T*,int&>x){return is>>tie(get<1>(x),get<0>(x));}
}
TMPL_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
TMPL_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}

inline int in(){int x;std::cin>>x;return x;}

struct Initializer_ {
  Initializer_(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(0);
    std::cout << std::setprecision(10);
    std::cerr << std::setprecision(10);
  }
} precalc;
// clang-format on
// }}}

using namespace std;

#define int long long

const int INF = 1 << 29;

struct Solver {
  const int n, m, c, s, g;
  vector<vector<int>> Q, R, sum;
  Solver(int n, int m, int c, int s, int g)
      : n(n), m(m), c(c), s(s - 1), g(g - 1), Q(c), R(c), sum(c) {}
  int solve() {
    static Int way[20][100][100];
    REP(i, c) REP(j, n) REP(k, n) way[i][j][k] = INF;
    REP(i, c) REP(j, n) way[i][j][j] = 0;
    REP(m) {
      int xi = in() - 1, yi = in() - 1, di = in(), ci = in() - 1;
      chmin(way[ci][xi][yi], di);
      chmin(way[ci][yi][xi], di);
    }
    vector<int> P;
    extio::read_seq(P, c);
    REP(i, c) {
      const int p = P[i];
      Q[i].emplace_back(0);
      extio::read_seq(Q[i], p - 1);
      Q[i].emplace_back(1ll << 60);
      for (auto&& q : Q[i]) {
        q++;
      }
      extio::read_seq(R[i], p);
      sum[i].resize(p);
      sum[i][0] = 0;
      REP(j, 1, p) { sum[i][j] = sum[i][j - 1] + (Q[i][j] - Q[i][j - 1]) * R[i][j - 1]; }
    }
    Int cost[100][100];
    REP(i, n) REP(j, n) cost[i][j] = INF;
    REP(a, c) {
      REP(k, n) REP(i, n) REP(j, n) chmin(way[a][i][j], way[a][i][k] + way[a][k][j]);
      REP(i, n) REP(j, n) chmin(cost[i][j], calc_cost(a, way[a][i][j]));
    }
    REP(k, n) REP(i, n) REP(j, n) chmin(cost[i][j], cost[i][k] + cost[k][j]);
    if (cost[s][g] == INF) { return -1; }
    return cost[s][g];
  }
  inline int calc_cost(int ci, int dist) const {
    if (dist == 0) return 0;
    int idx = upper_bound(ALL(Q[ci]), dist) - Q[ci].begin() - 1;
    return sum[ci][idx] + (dist - Q[ci][idx] + 1) * R[ci][idx];
  }
};

signed main() {
  int n, m, c, s, g;
  while (n = in(), m = in(), c = in(), s = in(), g = in(), n || m || c || s || g) {
    Solver solver(n, m, c, s, g);
    cout << solver.solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 4792