One Pass of the Line-Painting Truck
The city's road-maintenance team has one line-painting truck, and this season it must repaint the centre line of every road. Paint is expensive and the truck's sprayer can't be switched off on the move, so the dispatcher wants a single route that drives along every road exactly once. The truck may never drive over a road it has already painted.
The map has n junctions numbered 1 to n and m two-way roads numbered 1 to m. Road i joins junctions u_i and v_i. Two junctions may be joined by several parallel roads, and a road may start and end at the same junction (a loop road around a cul-de-sac); driving a loop road takes the truck back to the junction where it started. Junctions without any road don't matter.
The truck can be dropped off at any junction and picked up wherever its route ends; the route doesn't have to return to its start.
Find such a route, or report that none exists.
Input
The first line contains two integers n and m (1 ≤ n ≤ 2·10^5, 1 ≤ m ≤ 2·10^5), the number of junctions and roads.
Each of the next m lines contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ n), the junctions joined by road i. u_i = v_i is a loop road.
Output
If no route drives along every road exactly once, print IMPOSSIBLE.
Otherwise print two lines. The first line contains the starting junction s. The second line contains m integers, the road numbers in the order the truck drives them. The first road must touch s, and each next road must touch the junction where the truck stands after the previous road. Every road from 1 to m must appear exactly once.
If there are several valid routes, print any of them.
Notes
In the first example the numbers of road ends at the junctions are 1, 6, 4 and 1 (a loop road counts twice at its junction). The answer drives 1 → 2 → 2 → 3 → 2 → 3 → 4 over roads 1, 2, 3, 4, 5, 6. Starting at junction 4 with roads 6, 5, 4, 3, 2, 1 is also accepted.
In the second example all three roads leave junction 1, towards junctions 2, 3 and 4. Each time the truck passes through a junction it uses one road to arrive and another to leave, so only the two ends of a route can have an odd number of road ends. Here four junctions do, so the answer is IMPOSSIBLE.
Junction 5 in the second example has no roads and is ignored.