require 'set'

### constant

MAX_INT = 1 << 30

### main

n, m, kn, qn = gets.strip.split(' ').map{|s| s.to_i}

edges = {}
nbrs = {}

m.times do
  ai, bi, li = gets.strip.split(' ').map{|s| s.to_i}
  ai -= 1
  bi -= 1

  if edges[ai].nil?
    edges[ai] = {}
    nbrs[ai] = Set.new
  end
  if edges[bi].nil?
    edges[bi] = {}
    nbrs[bi] = Set.new
  end

  edges[ai][bi] = edges[bi][ai] = li
  nbrs[ai] << bi
  nbrs[bi] << ai
end
#p edges
#p nbrs

dists = n.times.map{MAX_INT}
q = []

kn.times do
  fi = gets.strip.to_i - 1
  dists[fi] = 0
  q << fi
end
#p dists

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

  du = dists[u]

  for v in nbrs[u]
    dv = dists[v]
    duv = dists[u] + edges[u][v]
    if dv > duv
      dists[v] = duv
      if dv >= MAX_INT
        q << v
      end
    end
  end
end
#p dists

qn.times do
  si, ti = gets.strip.split(' ').map{|s| s.to_i - 1}

  min_dist = [dists[si], dists[ti]].min
  #p [si, ti, min_dist]

  qnbrs = Set.new(nbrs[si])
  visited = n.times.map{false}
  visited[si] = true

  while ! visited[ti]
    qnbrs0 = qnbrs.clone
    max_ndist = 0
    max_nv = nil

    for v in qnbrs0
      if visited[v]
        qnbrs.delete v
        next
      end

      if max_ndist < dists[v]
        max_ndist = dists[v]
        max_nv = v
      end
    end

    visited[max_nv] = true
    qnbrs += nbrs[max_nv]

    min_dist = max_ndist if min_dist > max_ndist
  end

  puts min_dist
end