Journey

No attempts yetTime limit1sMemory limit128 MB

Statement

There are $n$ cities in Byteland (numbered from $1$ to $n$), connected by bidirectional roads. There are only $n-1$ roads, yet they connect the cities so that it is possible to travel from any city to any other city (in other words, the cities and roads form a tree).

A traveller named Byterider arrived in city number $k$. He plans a journey that starts in city $k$ and passes through the cities $m_1, m_2, \dots, m_j$ he wants to visit (in any order). These city numbers are all distinct and all different from $k$. Byterider has only a limited amount of money, so he wants to visit all the planned cities using the shortest possible path (starting in city $k$). A path is a single road or a sequence of roads, where each next road starts in the city where the previous one ends. Determine the length of the shortest path for Byterider's journey.

Write a program which

  • reads from standard input:
    • the description of the roads connecting the cities of Byteland,
    • the number of the city where Byterider arrived,
    • the list of cities Byterider would like to visit,
  • computes the minimum length of Byterider's journey,
  • writes the result to standard output.

Input

The first line contains two integers $n$ and $k$ separated by a single space ($2 \le n \le 50000$, $1 \le k \le n$), where $n$ is the number of cities and $k$ is the number of the first city on Byterider's path. Each of the next $n-1$ lines describes one road. The $i$-th of these lines ($1 \le i \le n-1$) contains three integers $a_i$, $b_i$, and $d_i$ separated by single spaces ($1 \le a_i, b_i \le n$, $1 \le d_i \le 1000$); $a_i$ and $b_i$ are the cities connected by the road, and $d_i$ is its length. The next line contains one integer $j$, the number of cities Byterider would like to visit ($1 \le j \le n-1$). The following line contains $j$ distinct integers $m_i$ separated by single spaces, the numbers of the cities Byterider wants to visit ($1 \le m_i \le n$, $m_i \ne k$).

Output

Print a single integer: the length of the shortest path for Byterider's journey.

Hint