This page is still under construction.

Parts of this page are still being built. What you see may change.

Crowd Control

Time limit2sMemory limit512 MB

Summary
Find the unique maximum-capacity simple path from node 0 to node n-1 and list every other edge incident to a vertex on that path that must be closed.
Level

Hard8 of 10

Topics
Graph, Shortest path, Greedy, DFS
Solved
No attempts yet

Problem

A programming contest brings a large number of visitors to Amsterdam. Most of them arrive at the train station and then walk to the contest venue in one big parade, moving from intersection to intersection along the streets.

Each street allows only a certain number of people per hour to pass through. That number is the capacity of the street. The number of people going through a street must never exceed its capacity, because otherwise accidents happen. People may walk through a street in either direction.

The organizers prepare a single path from the train station to the venue. The capacity of a path is the minimum capacity of any street on the path, and the organizers choose the path with maximum capacity. So that nobody walks the wrong way, they close down every street that has one of its endpoints at an intersection on the path but is not itself part of the path.

You are given the graph of the streets and intersections of Amsterdam. Write a program that prints which streets must be closed down in order to create a single maximum-capacity path from the train station to the venue. The path must be simple, so it may not visit any intersection more than once.

Input

The first line contains two integers nn, the number of intersections in the city, and mm, the number of streets (1≤n,m≤10001 \le n, m \le 1000).

Each of the following mm lines describes one street with three integers aia_i, bib_i and cic_i, where aia_i and bib_i are the ids of the two intersections connected by this street (0≤ai,bi<n0 \le a_i, b_i < n) and cic_i is the capacity of this street (1≤ci≤5000001 \le c_i \le 500000). Streets are numbered from 00 to m−1m - 1 in the given order.

The input always satisfies the following:

  • All visitors start at the train station, which is the intersection with id 00, and the venue is at the intersection with id n−1n - 1.
  • The intersections and streets form a connected graph.
  • No two streets connect the same pair of intersections.
  • No street has the same intersection at both ends.
  • The simple path of maximum capacity is unique.

Output

Print one line with the numbers of the streets that must be blocked in order to create a single maximum-capacity path from the train station to the venue, separated by single spaces. Sort the numbers in increasing order.

If no street must be blocked, print none instead.

Hint

The figure illustrates the first example input.

Examples3

  1. Example 1

    Input
    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
    
    Expected output
    0 2 4 6 7 8
    
  2. Example 2

    Input
    4 4
    0 1 10
    1 2 50
    0 3 30
    1 3 20
    
    Expected output
    0 3
    
  3. Example 3

    Input
    4 3
    0 1 10
    1 2 20
    2 3 30
    
    Expected output
    none