Oleg and Cola
시간 제한2초메모리 제한256 MB
1번 교차로에서 2번까지 갔다가 돌아오는 경로 중 도로의 광도가 감소하지 않는 가장 짧은 경로를 찾아 도로 번호 순서를 출력한다.
문제
Oleg is a cool programmer. Oleg lives in Ekaterinozavodsk. One day Oleg was writing code and didn't notice how night has come. As ill luck would have it, Oleg has run out of The Cola. There is only one 24-hour store with The Cola in Ekaterinozavodsk. So Oleg decided to go and buy his favorite Cola.
There are crossroads and two-way roads between them in Ekaterinozavodsk. Every road has length and luminosity which are defined by integers. Oleg lives near crossroad number , and the store is located at the crossroad number .
Oleg has to go from his home to the store and come back home. Oleg thinks that it is dangerous to decrease the luminosity of the roads during the way, so Oleg won't do it. This rule includes the last road before the store and the first road after it. Oleg can start with a road with arbitrary luminosity.
Please help Oleg to find the shortest path which Oleg finds safe. The length of the path is the sum of road lengths for every road the path includes. If Oleg uses one road twice then the length will be counted twice (and so on). As you remember, Oleg is a cool programmer and he likes The Cola very much, so he can always buy The Cola and come back home. In other words, a solution is guaranteed to exist.
입력
The first line contains two integers and : the number of crossroads and roads respectively (, ).
Each of the next lines describes a single road. Each description is in the format (, , ). Here, and are two crossroads joined by the road, is the length of the road, and is its luminosity.
There can be roads which connect a crossroad to itself. There can be several roads between a pair of crossroads, including roads with different lengths and/or luminosities.
출력
On the first line, print one integer: the length of the path.
On the second line, print the sequence of road numbers in the order Oleg should follow, separated by spaces. Roads are numbered from to in the input order.
If there are several solutions, print any one of them.