I. The Kunming-Singapore Railway
time limit per test
3 seconds
memory limit per test
128 megabytes
input
standard input
output
standard output

The Kunming-Singapore Railway is a network of rail tracks (some already built, some under construction) connecting several Asian cities. The project started in 1900 with the goal to connect Kunming (China) to Singapore, through the British Empire. Afterwards, in 1918, the railway was connected to Thailand through rail track joining Bangkok and Singapore. In 2000, ASEAN (Association of Southeast Asian Nations) considered completing this railway system.

The project is scheduled for completion by 2020. Due to its importante for Southeast Asia integration, the contractors hired you to minimize the system maintenance cost. Given N cities that make up the Kunming-Singapore network, M initial rail tracks in the system and the Q tracks that will be built over time, you are required to compute the minimum cost do maintain the network connected after building each of these Q tracks. The system is initially connected if, for each pair of cities, there a set of tracks joining one to the other.

Input

The first line has a single integer T, the number of test cases.

Each test case spans several lines. The first line has three space-separated integers, N, M, and Q (described above). The next M lines describe the initial rail tracks, and the next Q lines describe the tracks to be added over time. Each track is represented as three space-separated integers, ab, and c, where a and b represent the cities that are endpoints of the track, and c is the maintenance cost.

Limits

• 1 ≤ T ≤ 8
• 1 ≤ N, M, Q ≤ 3 × 104
• The sum of all N, M and Q over all test cases will not exceed 3·105
• 1 ≤ a, b ≤ N
• 1 ≤ c ≤ 105
Output

For each test case, print Q lines. The ith line among these must have a single integer, the minimum maintenance cost after adding the ith track.

Example
Input
14 3 51 2 52 3 63 4 71 4 81 2 42 4 53 4 51 4 6
Output
1817151414