Given vertices and weighted bidirectional edges, Bruce knows how to find the Minimal Spanning Tree (MST). But if the weight of each edge is changing, Bruce doesn't know how to efficiently find the MST after each change. Can you write a program to help Bruce?
The first line of input will consist of three integers, , and , which are the number of vertices, number of edges, and number of weight changes.
Each of the next lines will consist of three integers, , and (, ), which represents the bidirectional edge between and has the cost .
Each of the next lines will consist of two integers, and (, ), which represents the th edge's cost changes to .
Output lines. The line consists of 1 integer, the cost of MST after the first changes.
20% cases , , .
40% cases , , .
100% cases , , .
5 5 3 1 2 1 2 3 2 3 4 3 4 5 4 5 1 5 1 6 1 1 5 3
14 10 9