### constant

INF = 1 << 30
MAX_D = 20000

### subroutines

### main

loop do
  n, m, cn, st, gl = gets.split.map(&:to_i)
  break if (n | m | cn | st | gl) == 0

  st -= 1
  gl -= 1
  
  edges = cn.times.map{n.times.map{n.times.map{nil}}}
  nbrs = cn.times.map{n.times.map{[]}}
  
  m.times do
    xi, yi, di, ci = gets.split.map(&:to_i)
    xi -= 1
    yi -= 1
    ci -= 1

    if edges[ci][xi][yi].nil?
      edges[ci][xi][yi] = edges[ci][yi][xi] = di
      nbrs[ci][xi] << yi
      nbrs[ci][yi] << xi
    elsif edges[ci][xi][yi] > di
      edges[ci][xi][yi] = edges[ci][yi][xi] = di
    end
  end
  #p edges
  #p nbrs

  pns = gets.split.map(&:to_i)
  cpr = cn.times.map{[0]}
  
  for ci in (0...cn)
    qis = gets.split.map(&:to_i) + [INF]
    ris = gets.split.map(&:to_i)

    k = 0
    for d in (1..MAX_D)
      k += 1 if qis[k] < d
      cpr[ci][d] = cpr[ci][d - 1] + ris[k]
    end
  end    
  #p $qis
  #p $ris
  #p $fis

  min_ds = cn.times.map{n.times.map{n.times.map{INF}}}
  
  for ci in (0...cn)
    for st0 in (0...n)
      dists = n.times.map{INF}
      dists[st0] = 0
      q = [st0]

      while ! q.empty?
        u = q.min{|a, b| dists[a] <=> dists[b]}
        q.delete(u)

        ud = dists[u]
        for v in nbrs[ci][u]
          nvd = ud + edges[ci][u][v]
          vd = dists[v]
          if vd > nvd
            q << v if vd >= INF
            dists[v] = nvd
          end
        end
      end

      for gl0 in (0...n)
        next if st0 == gl0
        d = dists[gl0]
        if min_ds[ci][st0][gl0] > d
          min_ds[ci][st0][gl0] = d
        end
      end
    end
  end
  #p min_ds

  costs = n.times.map{n.times.map{INF}}

  for st0 in (0...n)
    for gl0 in (0...n)
      next if st0 == gl0
      min_c = INF
      for ci in (0...cn)
        md = min_ds[ci][st0][gl0]
        if md < INF
          pr = cpr[ci][md]
          costs[st0][gl0] = pr if costs[st0][gl0] > pr
        end
      end
    end
  end
  #p costs

  prices = n.times.map{INF}
  prices[st] = 0
  q = [st]

  while ! q.empty?
    u = q.min{|a, b| prices[a] <=> prices[b]}
    q.delete(u)

    break if u == gl

    up = prices[u]

    for v in (0...n)
      cv = costs[u][v]
      next if cv >= INF

      nvp = up + cv
      vp = prices[v]

      if vp > nvp
        q << v if vp >= INF
        prices[v] = nvp
      end
    end
  end

  puts (prices[gl] >= INF) ? -1 : prices[gl]
end