### constant

INF = 1 << 30

### main

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

  scty, dcty = gets.strip.split

  nc = 0
  chash = {}
  rds = []
  
  n.times do
    cti0, cti1, di = gets.strip.split

    if chash[cti0].nil?
      chash[cti0] = nc
      nc += 1
    end
    if chash[cti1].nil?
      chash[cti1] = nc
      nc += 1
    end

    c0 = chash[cti0]
    c1 = chash[cti1]
    di = di.to_i

    rds << [c0, c1, di]
  end

  edges = Array.new(nc){Array.new(nc){nil}}
  nbrs = Array.new(nc){[]}

  rds.each do |c0, c1, di|
    edges[c0][c1] = edges[c1][c0] = di
    nbrs[c0] << c1
    nbrs[c1] << c0
  end
  #p edges
  #p nbrs

  gss = Array.new(nc){false}
  m.times do
    gss[chash[gets.strip]] = true
  end
  #p gss

  sc = chash[scty]
  dc = chash[dcty]
  #p [sc, dc]

  max_d = cap * 10

  dists = Array.new(nc){Array.new(max_d + 1){INF}}
  dists[sc][0] = 0
  q = [[sc, 0]]

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

    uc, ug = u
    next if uc == dc

    ud = dists[uc][ug]
    ug = 0 if gss[uc]
    
    for vc in nbrs[uc]
      vg = ug + edges[uc][vc]
      next if vg > max_d

      nvd = ud + edges[uc][vc]
      if dists[vc][vg] > nvd
        dists[vc][vg] = nvd
        q << [vc, vg]
      end
    end
  end

  min_d = dists[dc].min
  puts (min_d >= INF ? -1 : min_d)
end