text: import sys
  import heapq
  
  
  def sol():
      # sys.stdin = open("./9370/input.txt")
      input = sys.stdin.readline
      T = int(input())
      for _ in range(T):
          n, m, t = map(int, input().split())
          s, g, h = map(int, input().split())
          graph = {i: set() for i in range(1, n + 1)}
          for __ in range(m):
              a, b, d = map(int, input().split())
              if (a == g and b == h) or (a == h and b == g):
                  graph[a].add((b, d * 2 - 1))
                  graph[b].add((a, d * 2 - 1))
              else:
                  graph[a].add((b, d * 2))
                  graph[b].add((a, d * 2))
          target_ends = [int(input()) for ___ in range(t)]
          dist = dijkstra(n, graph, s)
          result = []
          for end in target_ends:
              if dist[end] != sys.maxsize and dist[end] % 2 == 1:
                  result.append(end)
          print(*sorted(result))
  
  
  def dijkstra(n, graph, start):
      max_int = sys.maxsize
      dist = [max_int] * (n + 1)
      dist[start] = 0
      heap = []
      for i in range(1, n + 1):
          heapq.heappush(heap, (dist[i], i))
      while heap:
          d, u = heapq.heappop(heap)
          if d > dist[u]:
              continue
          for v, w in graph[u]:
              if dist[v] > dist[u] + w:
                  dist[v] = dist[u] + w
                  heapq.heappush(heap, (dist[v], v))
      return dist
  
  
  if __name__ == "__main__":
      sol()
  