AT_past19_i 道の沈没

Description

AtCoderLand has $ N $ islands: island $ 1 $ , island $ 2 $ , $ \ldots $ , and island $ N $ , and $ M $ roads: road $ 1 $ , road $ 2 $ , $ \ldots $ , and road $ M $ . Road $ i $ connects island $ A_i $ and island $ B_i $ bidirectionally. Road $ i\ (1\leq i\leq M) $ will be submerged on day $ D_i $ , so it will not be available on or after day $ D_i $ . The islands are said to be connected if one can travel between any pair of islands via available roads. On day $ 0 $ (when no road is submerged), the islands are connected. Find the integer $ X $ such that the islands are connected on day $ (X-1) $ but not on day $ X $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ $ M $ $ A _ 1 $ $ B _ 1 $ $ D _ 1 $ $ A _ 2 $ $ B _ 2 $ $ D _ 2 $ $ \vdots $ $ A _ M $ $ B _ M $ $ D _ M $

Output Format

Print the answer.

Explanation/Hint

### Sample Explanation 1 The islands of AtCoderLand are illustrated in the figure below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_past19_i/945541f5bccd84434afd8660f0c8cf3b7c53cc93017e1bae3609d9f2701ecbbd.png) On day $ 24 $ , the islands are connected. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_past19_i/3e75299a3af11bf787d86359d5230d754f8fbd1f4d880a1b680e7134f629a7f5.png) On day $ 25 $ , road $ 2 $ will be submerged, making it impossible to travel between, for instance, island $ 1 $ and island $ 2 $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/AT_past19_i/45bf2a5e4af2169acb1ed4d7e209e43356a46595e8130191e2f5b3beb0aacc70.png) Thus, $ 25 $ should be printed. ### Sample Explanation 2 There may be a road that leads from an island to itself, or multiple roads between the same pair of islands. ### Constraints - $ 2\leq N\leq2\times10 ^ 5 $ - $ N-1\leq M\leq2\times10 ^ 5 $ - $ 1\leq A _ i\leq B _ i\leq N\ (1\leq i\leq M) $ - $ 1\leq D _ i\leq10 ^ 9\ (1\leq i\leq M) $ - The islands are initially connected. - All input values are integers.