You are given a network of `n` nodes labeled `1` to `n` and a list `times` where `times[i] = [u, v, w]` means a signal travels from `u` to `v` in `w` time.
Send a signal from node `k`. Return the time it takes for **all** nodes to receive the signal, or `-1` if some node is unreachable.
Example 1
Input:times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2
Output:2
Explanation:The farthest node (4) receives the signal at time 2.
Example 2
Input:times = [[1,2,1]], n = 2, k = 2
Output:-1
Explanation:Node 1 is unreachable from 2.
Constraints
- 1 <= k <= n <= 100
- 1 <= times.length <= 6000
- All (u, v) pairs are unique