eolymp
bolt
Try our new interface for solving problems
Problems

Network Wars

Network Wars

Network of Byteland consists of n servers, connected by m optical cables. Each cable connects two servers and can transmit data in both directions. Two servers of the network are especially important - they are connected to global world network and president palace network respectively.

The server connected to the president palace network has number 1, and the server connected to the global world network has number n.

Recently the company Max Traffic has decided to take control over some cables so that it could see what data is transmitted by the president palace users. Of course they want to control such set of cables, that it is impossible to download any data from the global network to the president palace without transmitting it over at least one of the cables from the set.

To put its plans into practice the company needs to buy corresponding cables from their current owners. Each cable has some cost. Since the company’s main business is not spying, but providing internet connection to home users, its management wants to make the operation a good investment. So it wants to buy such a set of cables, that cables mean cost is minimal possible.

That is, if the company buys k cables of the total cost c, it wants to minimize the value of c / k.

Input

The first line contains n and m (2n100, 1m400). Next m lines describe cables - each cable is described with three integer numbers: servers it connects and the cost of the cable. Cost of each cable is positive and does not exceed 107.

Any two servers are connected by at most one cable. No cable connects a server to itself. The network is guaranteed to be connected, it is possible to transmit data from any server to any other one.

Output

First output k - the number of cables to buy. After that output the cables to buy themselves. Cables are numbered starting from one in order they are given in the input file.

Time limit 1 second
Memory limit 128 MiB
Input example #1
6 8
1 2 3
1 3 3
2 4 2
2 5 2
3 4 2
3 5 2
5 6 3
4 6 3
Output example #1
4
3 4 5 6
Source 2004 Petrozavodsk, Summer, Andrew Stankevich Contest 7, August 22, Problem G