Secret Meeting

Given a weighted undirected graph and K friends' rooms, pick the room minimizing the sum of shortest-path distances from all friends; break ties by smallest room.

Medium4Shortest pathGraphBrute forceInterviewNo attempts yetTime limit1sMemory limit128 MB

Problem

Harry and his friends want to hold a secret meeting to practice Defence Against the Dark Arts away from Umbridge's watch. They pass the location with fake Galleons. When Harry writes a place on his own Galleon, the same place appears on the Galleons his friends carry.

Hogwarts has NN rooms that suit the meeting. Each room carries one number from 1 to NN, and no number repeats. The rooms are joined by MM secret passages built with magic. Every passage can be walked in both directions and its length is a natural number. KK friends attend the meeting.

Harry picks one of the NN rooms as today's meeting place. Before he picks it he checks the Hogwarts secret map and finds the friends standing in different rooms, one friend per room. Apparition is banned inside Hogwarts, so each friend walks to the meeting place through secret passages only, and always along a shortest route from the room where they started. The travel distance of a friend is the sum of the lengths of the passages on that route.

Harry uses the room that makes the total travel distance of the attending friends as small as possible. The picture below shows an example with N=6N = 6, M=7M = 7, K=2K = 2.

The number in each vertex is a room number, and the number on each edge is the length of the passage between those two rooms. The two friends are in room 3 and room 5. If room 2 becomes the meeting place, the friend in room 3 walks 3, 2 for a travel distance of 2, and the friend in room 5 walks 5, 1, 3, 2 for a travel distance of 5, so the total is 7. If room 1 becomes the meeting place, the two travel distances are 1 and 2 and the total is 3. In this example rooms 1, 3 and 5 all reach the smallest total, 3.

Once Harry writes the meeting place on the fake Galleon, the KK friends learn it at once, stop what they are doing and leave for that room. Write a program that finds the meeting place minimizing the total travel distance of the friends.

Input

Input is read from standard input. The first line holds the number of test cases TT.

The first line of each test case holds the number of rooms NN and the number of secret passages MM, separated by a space (2N1002 \le N \le 100, N1MN(N1)/2N - 1 \le M \le N(N-1)/2). Each of the next MM lines holds one passage as aa, bb, cc. Here aa and bb are the numbers of the two rooms the passage joins, and cc is its length. aa and bb are always different, and cc is a natural number between 1 and 1000. At most one passage joins any pair of rooms, and no passage is listed twice. Every room can be reached from every other room through passages.

The next line holds the number of attending friends KK (1KN1 \le K \le N). The last line of each test case holds the KK room numbers where the friends stand, separated by spaces. Those numbers lie between 1 and NN and are all different, so two friends are never in the same room.

Output

Output is written to standard output. For each test case print, on a line of its own and in the order the test cases are given, the number of the room that minimizes the total travel distance of the friends. If several rooms reach that minimum, print the smallest such room number.