A wireless mesh network has n nodes, numbered 0 to n - 1, and m two-way links.
Link i connects nodes u and v and can carry w units of bandwidth. Data sent along a multi-hop
route can only flow as fast as the slowest (minimum-bandwidth) link on that route.
Given a source node s and a destination node t (with s != t), print the highest achievable
end-to-end bandwidth over any route from s to t, where a route's bandwidth is the minimum link
weight along it. If t cannot be reached from s, print -1 instead.
Input format
Line 1: two integers n m.
Next m lines: three integers u v w -- an undirected link between nodes u and v with bandwidth
w (nodes are 0-indexed).
Last line: two integers s t.
Output format
A single integer: the maximum possible end-to-end bandwidth from s to t, or -1 if unreachable.
Constraints
- 2 <= n <= 1000
- 0 <= m <= 4000
- 0 <= u, v < n, u != v
- 1 <= w <= 1000000
- 0 <= s, t < n, s != t