CF587D Duff in Mafia

Description

Duff is one if the heads of Mafia in her country, Andarz Gu. Andarz Gu has $ n $ cities (numbered from 1 to $ n $ ) connected by $ m $ bidirectional roads (numbered by $ 1 $ to $ m $ ). Each road has a destructing time, and a color. $ i $ -th road connects cities $ v_{i} $ and $ u_{i} $ and its color is $ c_{i} $ and its destructing time is $ t_{i} $ . Mafia wants to destruct a matching in Andarz Gu. A matching is a subset of roads such that no two roads in this subset has common endpoint. They can destruct these roads in parallel, i. e. the total destruction time is a maximum over destruction times of all selected roads. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF587D/a53c23915fc4382f2bfe77b7372f450a1320cd80.png)They want two conditions to be satisfied: 1. The remaining roads form a proper coloring. 2. Destructing time of this matching is minimized. The remaining roads after destructing this matching form a proper coloring if and only if no two roads of the same color have same endpoint, or, in the other words, edges of each color should form a matching. There is no programmer in Mafia. That's why Duff asked for your help. Please help her and determine which matching to destruct in order to satisfied those conditions (or state that this is not possible).

Input Format

N/A

Output Format

N/A

Explanation/Hint

Graph of Andarz Gu in the first sample case is as follows: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF587D/9fdcf9000b9849deb07ed2166ba017b10266938b.png)A solution would be to destruct the roads with crosses. Graph of Andarz Gu in the second sample case is as follows: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF587D/80047b1233eefc696bafab007d4617701f011cf8.png)