AT_abc486_e [ABC486E] Increasing Walk
Description
There is a graph with $ N $ vertices and $ M $ edges, where the vertices are numbered $ 1 $ to $ N $ .
The $ i $ -th edge is an undirected edge connecting vertex $ U_i $ and vertex $ V_i $ , with weight $ C_i $ .
Find the maximum total edge weight of a walk in this graph along which the edge weights are strictly increasing.
You are given $ T $ cases; solve each of them.
What is a walk?A sequence $ (v_0,e_1,v_1,e_2,\dots,e_k,v_k) $ in which vertices and edges alternate is called a walk if it satisfies the following condition. - $ e_i $ connects $ v_{i-1} $ and $ v_i $ for every $ i $ .
Input Format
The input is given from Standard Input in the following format:
> $ T $ $ \mathrm{case}_1 $ $ \mathrm{case}_2 $ $ \vdots $ $ \mathrm{case}_T $
Each test case is given in the following format:
> $ N $ $ M $ $ U_1 $ $ V_1 $ $ C_1 $ $ U_2 $ $ V_2 $ $ C_2 $ $ \vdots $ $ U_M $ $ V_M $ $ C_M $
Output Format
Print $ T $ lines. The $ i $ -th line should contain the answer for the $ i $ -th test case.
Explanation/Hint
### Sample Explanation 1
For the $ 1 $ -st test case, as shown in the figure below, the walk $ 1 \to 3 \to 2 \to 5 \to 3 \to 6 $ has a total edge weight of $ 10+20+30+40+50=150 $ .
No walk along which the edge weights are strictly increasing has a larger total weight, so the answer is $ 150 $ .

### Constraints
- $ T \geq 1 $
- $ 2 \leq N \leq 2\times 10^5 $
- $ 1 \leq M \leq 2\times 10^5 $
- $ 1 \leq U_i < V_i \leq N $
- $ 1 \leq C_i \leq 10^9 $
- The pairs $ (U_i,V_i) $ are pairwise distinct.
- The sum of $ N $ over the $ T $ cases is at most $ 2\times 10^5 $ .
- The sum of $ M $ over the $ T $ cases is at most $ 2\times 10^5 $ .
- All input values are integers.