SP32679 ADAROADS - Ada and Roads
Description
As you might already know, Ada the Ladybug is a farmer. She grows many fruits and vegetables. She has to take care of them so she builds many roads between them. She also doesn't want to keep unnecessary roads so after builting a road she cleans the rest of roads so her road-system doesn't contain any needless cycles. Each road has some maintenance cost and she always keeps roads in such ways that the total cost is minimized.
Input Format
The first line of input containts **1 , the number of vegetables and the number of roads built by Ada.**
The next **M** lines contains three integers **a, b, c: 0 , the vegetables connected by road and its maintanance cost.**
To simulate the "real-time", **a, b, c** will be on input as **a ⊕ l, b ⊕ l, c ⊕ l**, where **l** is the last answer (start as 0) and operation stands for binary XOR.
Output Format
For each new road print the number actual best sum of maintenance costs.