twoavenues
Two Avenues
In order to make the capital of Berland a more attractive place for tourists, the great king came up with the following plan: choose two streets of the city and call them avenues. Certainly, these avenues will be proclaimed extremely important historical places, which should attract tourists from all over the world.
The capital of Berland can be represented as a graph, the vertices of which are crossroads, and the edges are streets connecting two crossroads. In total, there are vertices and edges in the graph, you can move in both directions along any street, you can get from any crossroad to any other by moving only along the streets, each street connects two different crossroads, and no two streets connect the same pair of crossroads.
In order to reduce the flow of ordinary citizens moving along the great avenues, it was decided to introduce a toll on each avenue in both directions. Now you need to pay tugrik for one passage along the avenue. You don't have to pay for the rest of the streets.
Analysts have collected a sample of citizens, of them needs to go to work from the crossroad to the crossroad . After two avenues are chosen, each citizen will go to work along the path with minimal cost.
In order to earn as much money as possible, it was decided to choose two streets as two avenues, so that the total number of tugriks paid by these citizens is maximized. Help the king: according to the given scheme of the city and a sample of citizens, find out which two streets should be made avenues, and how many tugriks the citizens will pay according to this choice.
Input format
The first line contains two integers and — the number of crossroads and streets, respectively.
The next lines contain the description of streets. The line contains two integers and — indexes of crossroads which are connected by the street. It is guaranteed that no two streets connect the same pair of crossroads, and you can get from any crossroad to any other by moving only along the streets.
The next line contains a single integer — the number of citizens in the sample.
The next lines contain the description of citizens. The line contains two integers and — citizen goes to work from crossroad to crossroad . Note that it is possible for .
Output format
Print the total amount of tugriks that will be paid by citizens.
Limits
Subtask #
|
Score
|
Constraints
|
1 |
6 |
|
2 |
7 |
|
3 |
10 |
|
4 |
16 |
|
5 |
20 |
The graph is a cactus; each edge is in at most one simple cycle. |
6 |
41 |
No additional constraints |
Samples
Sample Input 1
|
Sample Output 1
|
6 5
1 2
2 3
2 4
4 5
4 6
3
1 6
5 3
2 5
|
5
|
Sample Input 2
|
Sample Output 2
|
5 5
1 2
2 3
3 4
4 5
5 1
6
1 5
1 3
1 3
2 4
2 5
5 3
|
5
|
Sample Input 3
|
Sample Output 3
|
8 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
7 1
1 8
3 6
4
2 5
3 7
2 5
7 8
|
3
|