Evan is planning a new country. In his ideal country, there are cities connected by weighted directed roads. The weight of each road is the distance between the two cities it is connecting. These cities are grouped into provinces. A province, according to Evan, is a maximal group of cities such that every city is able to visit every other city in that province.
Evan wants to keep the provinces as segregated as possible for reasons we dare not know about. As such, he has decided that there will only be roads connecting the provinces. These roads are included in the initial roads. Furthermore, he has guaranteed that all provinces are connected, that is, each province has either an indegree greater than , an outdegree greater than , or both. In other words, the provinces form a tree.
Soon after, Evan is told that with his current plan, not every province can visit every other province. Realizing his mistake, he has decided that all roads between any two provinces will be upgraded to be bidirectional. The distance between city and city in both directions, however, will be the same.
With the country's roads planned out, Evan wants you to find the distance between two cities so that he can decide if any other roads need to be built. He will ask you times.
Input Specification
The first line will contain three space-separated integers, , , , the number of cities, roads, and queries respectively.
The next lines will each contain three space-separated integers, , indicating that there is a road connecting city and city of length .
The next lines will each contain two space-separated integers, , indicating that Evan would like to know the distance from city to city .
It is guaranteed that and . That is, the number of provinces is less than or equal to and the number of cities in each province is less than or equal to .
Constraints
Subtask 1 [8%]
Subtask 2 [16%]
Subtask 3 [16%]
Subtask 4 [60%]
No additional constraints.
Output Specification
For each query, output the minimum distance from to on a new line for Evan.
Sample Input 1
10 13 5
1 2 3
2 3 2
3 1 10
4 1 5
3 4 7
10 3 2
6 10 1
6 7 8
5 7 7
5 6 4
7 8 6
8 9 9
9 5 1
1 8
3 1
9 10
5 2
4 6
Sample Output 1
22
10
6
20
13
Sample Input 2
9 12 4
1 2 1
2 1 1
1 3 1
3 4 1
4 3 1
2 5 1
5 6 1
6 5 1
6 7 1
6 8 1
8 9 1
9 8 1
1 9
7 4
2 8
6 3
Sample Output 2
5
6
3
4
Sample Input 3
14 19 7
1 2 1
2 3 5
3 1 3
2 4 2
4 5 4
5 4 1
4 10 8
10 11 10
11 12 5
12 11 6
4 6 3
6 7 1
7 8 3
8 9 2
9 6 1
8 6 4
7 13 2
13 14 5
14 13 1
1 8
13 12
5 9
11 3
7 4
2 14
10 6
Sample Output 3
10
34
10
25
9
13
11
Comments
RIP evening.
Is the distance we have to find, the minimum possible distance?
Yes