- Time limit: 1.00 s
- Memory limit: 512 MB
There are cities and roads between them. Your task is to process queries where you have to determine the length of the shortest route between two given cities.
Input
The first input line has three integers , and : the number of cities, roads, and queries.
Then, there are lines describing the roads. Each line has three integers , and : there is a road between cities and whose length is . All roads are two-way roads.
Finally, there are lines describing the queries. Each line has two integers and : determine the length of the shortest route between cities and .
Output
Print the length of the shortest route for each query. If there is no route, print instead.
Constraints
Example
Input:
4 3 5 1 2 5 1 3 9 2 3 3 1 2 2 1 1 3 1 4 3 2
Output:
5 5 8 -1 3