Toll Roads

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

Your state has a number of cities, and the cities are connected by roads. Unfortunately, all of the roads are toll roads!

You now run the local chapter of AAA (American Automobile Association), and people are constantly asking you about the tolls. In particular, they've been asking about individual tolls on any single road on a path between two cities. Odd, but that's what they've been asking!

Given a description of the cities in your state and the roads that connect them, and a series of queries consisting of two separate cities, for each query determine two things:

  • First, the smallest value such that there is a route between the two cities where no road has a toll greater than that value.
  • Second, the number of cities reachable from your starting city using no road with a toll greater than that first value.

입력

The first line of input contains three integers nn (2n2×1052 \le n \le 2 \times 10^5), mm (1m2×1051 \le m \le 2 \times 10^5) and qq (1q2×1051 \le q \le 2 \times 10^5), where nn is the number of cities, mm is the number of roads, and qq is the number of queries. The cities are each identified by a number 11 through nn.

Each of the next mm lines contains three integers uu, vv (1u,vn,uv1 \le u,v \le n, u \ne v) and tt (0t2×1050 \le t \le 2 \times 10^5), which represents a road between cities uu and vv with toll tt. The roads are two-way, and the toll is the same in either direction. It is guaranteed that there is a path between any two cities, and that there is at most one road between any two cities.

Each of the next qq lines contains two integers aa and bb ( 1a,bn,ab1 \le a,b \le n, a \ne b). This represents a query about a path from aa to bb.

출력

Output qq lines. Each line is an answer to a query, in the order that they appear. Output two space-separated integers, ww and kk, on each line, where ww is the smallest amount such that there is a route from aa to bb with no toll greater that ww, and kk is the number of cities reachable from aa using no road with a toll greater than ww.