SP26054 MARYBMW - BMW

题目描述

玛丽非常开心,因为她的父母在她生日的时候送了一辆最新款的宝马车。为了试驾这辆新车,她决定去看望她的奶奶。 **本翻译由 AI 自动生成**

输入格式

The first line of the input contains the number of tests – $T$ ($T \le 5$). On the first line of each test case there are two integers – $N$ ($2 \le N \le 50000$) and $M$ ($1 \le M \le 100000$). On the next M lines there are three integers A, B, and V representing a bidirectional road between cities A and B with speed limit $V$ where $1 \le V \le 10^{18}$ (It's a BMW after all).

输出格式

On a single line print the maximum possible speed Mary can reach. If she can't reach her grandma's house, print `-1`.