#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

using T = tuple<int64, int64, int64>;
int64 n, m, c, s, g;
void calc() {
vector<PLL> G[20][110]; // (dis, to)
vector<vector<PLL>> cost;
vector<vector<int64>> csum;

  s--; g--;
  REP(i, m) {
    int64 x, y, d, com;
    cin >> x >> y >> d >> com; com--; x--; y--;
    G[com][x].emplace_back(d, y);
    G[com][y].emplace_back(d, x);
  }
  cost.resize(c);
  csum.resize(c);
  REP(i, c) {
    int64 p;
    cin >> p;
    cost[i].resize(p);
    csum[i].resize(p+1, 0);
  }
  REP(i, c) {
    cost[i][0].fs = 0;
    REP(j, cost[i].size()-1) cin >> cost[i][j+1].fs;
    REP(j, cost[i].size()) cin >> cost[i][j].sc;
    cost[i].push_back(PLL(INF_LL, 0));
//    REP(j, cost[i].size()) csum[i][j+1] = csum[i][j] + cost[i][j].fs*cost[i][j].sc;
  }

  auto calc_d = [&](int64 c, int64 d) {
    int64 ret = 0;
    REP(i, cost[c].size()-1) {
      if (cost[c][i+1].fs >= d) {
        ret += (d-cost[c][i].fs) * cost[c][i].sc;
        break;
      } else {
        ret += (cost[c][i+1].fs-cost[c][i].fs) * cost[c][i].sc;
      }
    }
    return ret;
  };

  vector<int64> d(n+1, INF_LL);
  vector<int64> toc(n+1, INF_LL);

  auto calc_cost = [&](int64 v, int64 com) {
    priority_queue<PLL, vector<PLL>, greater<PLL>> pq;
    toc[v] = 0;
    pq.emplace(0, v);
    while (pq.size()) {
      int64 vv, dd;
      tie(dd, vv) = pq.top(); pq.pop();
      if (toc[vv] < dd) continue;
      REP(i, G[com][vv].size()) {
        int64 u, cc;
        tie(cc, u) = G[com][vv][i];
        if (toc[u] > cc + toc[vv]) {
          toc[u] = cc + toc[vv];
          pq.emplace(toc[u], u);
        }
      }
    }
    REP(i, n) {
      if (toc[i] != INF_LL) toc[i] = calc_d(com, toc[i]);
    }
  };

  d[s] = 0;
  priority_queue<PLL, vector<PLL>, greater<PLL>> pq;
  pq.emplace(0, s);
  while (pq.size()) {
    int64 dd, vv;
    tie(dd, vv) = pq.top(); pq.pop();
    if (d[vv] < dd) continue;
    vector<int64> cc(n+1, INF_LL);
    REP(i, c) {
      fill(all(toc), INF_LL);
      calc_cost(vv, i);
      REP(j, n) cc[j] = min(cc[j], toc[j]);
    }
    REP(i, n) {
      if (d[i] > d[vv] + cc[i]) {
        d[i] = d[vv] + cc[i];
        pq.emplace(d[i], i);
      }
    }
  }
  cout << (d[g] != INF_LL ? d[g] : -1) << endl;
}

int main(void) {
  while (cin >> n >> m >>  c >> s >> g && n+m+c+s+g) {
    calc();
  }
}


Measured memory_bytes: 3584