#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct edge {
  int t, c, d;
  edge() {}
  edge(int t, int c, int d): t(t), c(c), d(d) {}
};
  
const int INF = 1 << 30;
int n, m, c, s, g;
int p[20], q[20][50], r[20][50];
int cost[20][20010];
int dis[20][110][110];
int dis2[110];
vector<edge> G[110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n >> m >> c >> s >> g, n) {
    s--; g--;
    fill_n((int*)dis, 20*110*110, INF);
    for (int t = 0; t < c; t++) {
      for (int i = 0; i < n; i++) {
        dis[t][i][i] = 0;
      }
    }
    for (int i = 0; i < 110; i++) {
      G[i].clear();
    }
    for (int i = 0; i < m; i++) {
      int x, y, d, cc;
      cin >> x >> y >> d >> cc;
      x--; y--; cc--;
      dis[cc][x][y] = dis[cc][y][x] = min(dis[cc][x][y], d);
    }
    for (int i = 0; i < c; i++) {
      cin >> p[i];
    }
    for (int i = 0; i < c; i++) {
      for (int j = 0; j < p[i]-1; j++) {
        cin >> q[i][j];
      }
      for (int j = 0; j < p[i]; j++) {
        cin >> r[i][j];
      }
    }
    for (int i = 0; i < c; i++) {
      for (int j = 1, last = 0; j < 20010; j++) {
        cost[i][j] = cost[i][j-1]+r[i][last];
        if (last < p[i]-1 && j == q[i][last]) last++;
      }
    }
    
    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++) {
            if (dis[t][i][k] == INF || dis[t][k][j] == INF) continue;
            dis[t][i][j] = min(dis[t][i][j], dis[t][i][k]+dis[t][k][j]);
          }
        }
      }
    }
    for (int t = 0; t < c; t++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          if (i == j || dis[t][i][j] == INF) continue;
          G[i].emplace_back(j, t, dis[t][i][j]);
        }
      }
    }

    fill_n((int*)dis2, 110, INF);
    dis2[s] = 0;
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.emplace(0, s);
    while (!que.empty()) {
      int d, cur;
      tie(d, cur) = que.top(); que.pop();
      if (dis2[cur] < d) continue;
      for (edge e : G[cur]) {
        if (dis2[e.t] > dis2[cur] + cost[e.c][e.d]) {
          dis2[e.t] = dis2[cur] + cost[e.c][e.d];
          que.emplace(dis2[e.t], e.t);
        }
      }
    }
    cout << (dis2[g] == INF ? -1 : dis2[g]) << endl;
  }

  return 0;
}
