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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

struct edge{
  int to;
  int dist;
  int cmp;
};

struct sta{
  int id;
  int dist;
};

int main(){
  while(1){
    int n,m,c,s,g;
    cin >> n >> m >> c >> s >> g;
    if(n==0) return 0;
    s--,g--;
    vector<vector<edge>> e(n);
    int x,y,d,cc;
    for(int i=0;i<m;i++){
      cin >> x >> y >> d >> cc;
      x--,y--;
      cc--;
      e[x].push_back({y,d,cc});
      e[y].push_back({x,d,cc});
    }
    vector<int> p(c);
    for(int i=0;i<c;i++) cin >> p[i];

    vector<vector<int>> un(c,vector<int>(20001));
    for(int i=0;i<c;i++){
      vector<int> q(p[i]-1),r(p[i]);
      for(int j=0;j<p[i]-1;j++) cin >> q[j];
      for(int j=0;j<p[i];j++) cin >> r[j];
      int now=0;
      for(int j=1;j<=20000;j++){
        if(now<p[i]-1) if(j>q[now]) now++;
        un[i][j]=un[i][j-1]+r[now];
      }
    }
    vector<int> ds(n,IINF);
    priority_queue<sta,vector<sta>,function<bool(sta,sta)>>
      heap([](const sta &a, const sta &b){return a.dist>b.dist;});
    heap.push({s,0});
    while(!heap.empty()){
      sta now = heap.top();
      heap.pop();
      if(ds[now.id]!=IINF) continue;
      // cout <<now.id+1 SP now.dist << endl;
      ds[now.id]=now.dist;
      for(int cmp=0;cmp<c;cmp++){
        priority_queue<sta,vector<sta>,function<bool(sta,sta)>>
          dijk([](const sta &a, const sta &b){return a.dist>b.dist;});
        vector<int> ddd(n,IINF);
        dijk.push({now.id,0});
        while(!dijk.empty()){
          auto nn=dijk.top();
          dijk.pop();
          if(ddd[nn.id]!=IINF) continue;
          ddd[nn.id] = nn.dist;
          for(auto nx:e[nn.id]){
            if(nx.cmp!=cmp) continue;
            if(ddd[nx.to]!=IINF) continue;
            dijk.push({nx.to,nn.dist+nx.dist});
          }
        }
        for(int i=0;i<n;i++){
          if(ddd[i]!=IINF&&ds[i]==IINF){
            heap.push({i,now.dist+un[cmp][ddd[i]]});
          }
        }
      }
    }
    if(ds[g]==IINF) cout << -1 << endl;
    else cout << ds[g] << endl;
  }
  return 0;
}

