CSES - Shortest Routes II
  • Time limit: 1.00 s
  • Memory limit: 512 MB

There are nn cities and mm roads between them. Your task is to process qq queries where you have to determine the length of the shortest route between two given cities.

Input

The first input line has three integers nn, mm and qq: the number of cities, roads, and queries.

Then, there are mm lines describing the roads. Each line has three integers aa, bb and cc: there is a road between cities aa and bb whose length is cc. All roads are two-way roads.

Finally, there are qq lines describing the queries. Each line has two integers aa and bb: determine the length of the shortest route between cities aa and bb.

Output

Print the length of the shortest route for each query. If there is no route, print 1-1 instead.

Constraints

  • 1n5001 \le n \le 500
  • 1mn21 \le m \le n^2
  • 1q1051 \le q \le 10^5
  • 1a,bn1 \le a,b \le n
  • 1c1091 \le c \le 10^9

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