Gossip Between Villages
The valley has n villages, numbered from 1 to n, and m footpaths. The i-th footpath joins villages u_i and v_i and takes w_i minutes to walk, in either direction. Two villages may be joined by several footpaths, possibly with different walking times, and a footpath may even start and end at the same village (a loop around the village pond).
News travels only on foot. When something happens in a village, a messenger sets off at once and may walk along any sequence of footpaths, passing through as many villages as needed; nobody ever waits along the way, and passing through a village costs no time. So the time for news to get from village a to village b is the smallest total walking time over all ways to walk from a to b. News that happens in a village is known there immediately, so the time from a village to itself is 0.
The village elders have q questions. Each question names two villages a and b and asks how many minutes it takes for news from village a to reach village b. If no sequence of footpaths leads from a to b, the news never arrives.
Input
The first line contains three integers n, m and q (1 ≤ n ≤ 300, 0 ≤ m ≤ 10^5, 1 ≤ q ≤ 10^5): the number of villages, footpaths and questions.
Each of the next m lines contains three integers u_i, v_i and w_i (1 ≤ u_i, v_i ≤ n, 1 ≤ w_i ≤ 10^9): a footpath between villages u_i and v_i that takes w_i minutes to walk. u_i may equal v_i.
Each of the next q lines contains two integers a and b (1 ≤ a, b ≤ n): a question. a may equal b.
Output
Print q lines. The j-th line must contain the answer to the j-th question: the smallest number of minutes for news from village a to reach village b, or -1 if it can never get there.
Notes
In the first example, villages 1 and 2 are joined by two footpaths taking 4 and 3 minutes. News from village 1 reaches village 4 fastest by walking 1 → 2 (3 minutes), 2 → 3 (1 minute) and 3 → 4 (2 minutes), 6 minutes in total; the direct footpath from 1 to 3 (7 minutes) is slower than going through village 2 (4 minutes). Village 5 has no footpaths at all, so news from it never reaches village 2.
In the second example, the loops around villages 1 and 3 never help: news is known in its own village at time 0.
Answers can exceed 2^31: a single walk may use many footpaths that each take up to 10^9 minutes.