The BAPC draws a large number of visitors to Amsterdam. Many of these people arrive at the train station, then walk from intersection to intersection through the streets of Amsterdam in a big parade until they reach the BAPC location.
A street can only allow a certain number of people per hour to pass through. This is called the capacity of the street. The number of people going through a street must never exceed its capacity, otherwise accidents will happen. People may walk through a street in either direction.
The BAPC organizers want to prepare a single path from train station to BAPC location. They choose the path with maximum capacity, where the capacity of a path is defined to be the minimum capacity of any street on the path. To make sure that nobody walks the wrong way, the organizers close down the streets which are incident^{1} to an intersection on the path, but not part of the path.
Can you write a program to help the organizers decide which streets to block? Given a graph of the streets and intersections of Amsterdam, produce the list of streets that need to be closed down in order to create a single maximum-capacity path from the train station to the BAPC. The path must be simple, i.e. it may not visit any intersection more than once.
The first line contains two integers: $n$, the number of intersections in the city, and $m$, the number of streets ($1 \le n,m \le 1000$).
The following $m$ lines each specify a single street. A street is specified by three integers, $a_ i$, $b_ i$ and $c_ i$, where $a_ i$ and $b_ i$ are ids of the two intersections that are connected by this street ($0 \le a_ i, b_ i < n$) and $c_ i$ is the capacity of this street ($1 \le c_ i \le 500000$). Streets are numbered from $0$ to $m-1$ in the given order.
You may assume the following:
All visitors start walking at the train station which is the intersection with id $0$. The BAPC is located at the intersection with id $n-1$.
The intersections and streets form a connected graph.
No two streets connect the same pair of intersections.
No street leads back to the same intersection on both ends.
There is a unique simple path of maximum capacity.
Output a single line containing a list of space separated street numbers that need to be blocked in order to create a single maximum-capacity path from train station to BAPC. Sort these street numbers in increasing order.
If no street must be blocked, output the word “none” instead.
Sample Input 1 | Sample Output 1 |
---|---|
7 10 0 1 800 1 2 300 2 3 75 3 4 80 4 5 50 4 6 100 6 1 35 0 6 10 0 2 120 0 3 100 |
0 2 4 6 7 8 |
Sample Input 2 | Sample Output 2 |
---|---|
4 4 0 1 10 1 2 50 0 3 30 1 3 20 |
0 3 |
Sample Input 3 | Sample Output 3 |
---|---|
4 3 0 1 10 1 2 20 2 3 30 |
none |
Footnotes