#P3905. 道路重建

道路重建

Description

Once, in a kingdom, there were mm roads connecting nn cities, and between any two cities there was at most one direct road. After a severe war, dd roads were destroyed. The king wants to repair the country's road system. Now, traffic between two important cities AA and BB is interrupted, and the king hopes to restore the connection between these two cities as soon as possible. Your task is to repair some roads to restore the connection between AA and BB, while minimizing the total length of the repaired roads.

Input Format

The first line contains an integer n (2<n100)n\ (2<n\le 100), representing the number of cities. These cities are numbered from 11 to nn.

The second line contains an integer m (n1m12n(n1))m\ (n-1\le m\le \dfrac{1}{2}n(n-1)), representing the number of roads.

Each of the next mm lines contains 33 integers i,j,k (1i,jn,ij,0<k100)i,j,k\ (1 \le i,j \le n,i\neq j,0<k \le 100), indicating that there is a road of length kk directly connecting city ii and city jj.

The next line contains an integer d (1dm)d\ (1\le d\le m), representing the number of roads that were destroyed after the war. In each of the following dd lines, there are two integers ii and jj, indicating that the road directly connecting city ii and city jj was destroyed.

The last line contains two integers AA and BB, representing the two important cities whose traffic needs to be restored.

Output Format

Output a single integer, representing the minimal total length of roads that must be repaired to restore traffic between AA and BB.

3
2
1 2 1
2 3 2
1
1 2
1 3
1

Hint

Translated by ChatGPT 5